Skip to content

Commit b331a20

Browse files
authored
Merge pull request mrRobot62#5 from mfalkvidd/keywords-fix
Update LOG_LEVEL_X comments
2 parents 3403b86 + 5a6fcff commit b331a20

File tree

3 files changed

+61
-56
lines changed

3 files changed

+61
-56
lines changed

ArduinoLog.h

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
_ ___ ___ _ _ ___ _ _ ___ _ ___ ___
2+
_ ___ ___ _ _ ___ _ _ ___ _ ___ ___
33
/_\ | _ \ \| | | |_ _| \| |/ _ \| | / _ \ / __|
44
/ _ \| / |) | |_| || || .` | (_) | |_| (_) | (_ |
55
/_/ \_\_|_\___/ \___/|___|_|\_|\___/|____\___/ \___|
6-
6+
77
Log library for Arduino
88
version 1.0.0
99
https://github.com/thijse/Arduino-Log
@@ -30,7 +30,7 @@ Licensed under the MIT License <http://opensource.org/licenses/MIT>.
3030
//#define DISABLE_LOGGING
3131

3232

33-
#define LOG_LEVEL_SILENT 0
33+
#define LOG_LEVEL_SILENT 0
3434
#define LOG_LEVEL_FATAL 1
3535
#define LOG_LEVEL_ERROR 2
3636
#define LOG_LEVEL_WARNING 3
@@ -49,12 +49,12 @@ Licensed under the MIT License <http://opensource.org/licenses/MIT>.
4949
All methods are able to handle any number of output parameters.
5050
All methods print out a formated string (like printf).<br>
5151
To reduce output and program size, reduce loglevel.
52-
52+
5353
Output format string can contain below wildcards. Every wildcard
5454
must be start with percent sign (\%)
55-
55+
5656
**** Wildcards
57-
57+
5858
* %s replace with an string (char*)
5959
* %c replace with an character
6060
* %d replace with an integer value
@@ -68,13 +68,13 @@ Licensed under the MIT License <http://opensource.org/licenses/MIT>.
6868
6969
**** Loglevels
7070
71-
* 0 - LOG_LEVEL_SILENT no output
72-
* 1 - LOG_LEVEL_FATAL fatal errors
73-
* 2 - LOG_LEVEL_ERROR all errors
74-
* 3 - LOG_LEVEL_WARNING errors, and warnings
75-
* 4 - LOG_LEVEL_NOTICE errors, warnings and notices
71+
* 0 - LOG_LEVEL_SILENT no output
72+
* 1 - LOG_LEVEL_FATAL fatal errors
73+
* 2 - LOG_LEVEL_ERROR all errors
74+
* 3 - LOG_LEVEL_WARNING errors and warnings
75+
* 4 - LOG_LEVEL_NOTICE errors, warnings and notices
7676
* 5 - LOG_LEVEL_TRACE errors, warnings, notices, traces
77-
* 6 - LOG_LEVEL_VERBOSE all
77+
* 6 - LOG_LEVEL_VERBOSE all
7878
*/
7979

8080
class Logging {
@@ -83,14 +83,14 @@ class Logging {
8383
bool _showLevel;
8484
Print* _logOutput;
8585
public:
86-
/*!
86+
/*!
8787
* default Constructor
8888
*/
8989
Logging()
9090
: _level(LOG_LEVEL_SILENT),
9191
_showLevel(true),
9292
_logOutput(NULL) {}
93-
93+
9494

9595
/**
9696
* Initializing, must be called as first. Note that if you use
@@ -104,124 +104,130 @@ class Logging {
104104
void begin(int level, Print *output, bool showLevel = true);
105105

106106
/**
107-
* Output an error message. Output message contains
108-
* ERROR: followed by original msg
109-
* Error messages are printed out, at every loglevel
110-
* except 0 ;-)
107+
* Output a fatal error message. Output message contains
108+
* F: followed by original message
109+
* Fatal error messages are printed out at
110+
* loglevels >= LOG_LEVEL_FATAL
111+
*
111112
* \param msg format string to output
112113
* \param ... any number of variables
113114
* \return void
114115
*/
115116
template <class T> void fatal(T msg, ...){
116-
#ifndef DISABLE_LOGGING
117+
#ifndef DISABLE_LOGGING
117118
if (LOG_LEVEL_FATAL <= _level) {
118119
if (_showLevel) _logOutput->print("F: ");
119120
va_list args;
120121
va_start(args, msg);
121122
print(msg,args);
122123
}
123-
#endif
124+
#endif
124125
}
125-
126+
126127
/**
127128
* Output an error message. Output message contains
128-
* ERROR: followed by original msg
129-
* Error messages are printed out, at every loglevel
130-
* except 0 ;-)
129+
* E: followed by original message
130+
* Error messages are printed out at
131+
* loglevels >= LOG_LEVEL_ERROR
132+
*
131133
* \param msg format string to output
132134
* \param ... any number of variables
133135
* \return void
134136
*/
135137
template <class T> void error(T msg, ...){
136-
#ifndef DISABLE_LOGGING
138+
#ifndef DISABLE_LOGGING
137139
if (LOG_LEVEL_ERROR <= _level) {
138140
if (_showLevel) _logOutput->print("E: ");
139141
va_list args;
140142
va_start(args, msg);
141143
print(msg,args);
142144
}
143-
#endif
145+
#endif
144146
}
145147
/**
146-
* Output an info message. Output message contains
147-
* Info messages are printed out at l
148-
* loglevels >= LOG_LEVEL_INFOS
148+
* Output a warning message. Output message contains
149+
* W: followed by original message
150+
* Warning messages are printed out at
151+
* loglevels >= LOG_LEVEL_WARNING
149152
*
150153
* \param msg format string to output
151154
* \param ... any number of variables
152155
* \return void
153156
*/
154157

155158
template <class T> void warning(T msg, ...){
156-
#ifndef DISABLE_LOGGING
159+
#ifndef DISABLE_LOGGING
157160
if (LOG_LEVEL_WARNING <= _level) {
158161
if (_showLevel) _logOutput->print("W: ");
159162
va_list args;
160163
va_start(args, msg);
161164
print(msg,args);
162165
}
163-
#endif
166+
#endif
164167
}
165168
/**
166-
* Output an debug message. Output message contains
167-
* Debug messages are printed out at l
168-
* loglevels >= LOG_LEVEL_DEBUG
169+
* Output a notice message. Output message contains
170+
* N: followed by original message
171+
* Notice messages are printed out at
172+
* loglevels >= LOG_LEVEL_NOTICE
169173
*
170174
* \param msg format string to output
171175
* \param ... any number of variables
172176
* \return void
173177
*/
174178

175179
template <class T> void notice(T msg, ...){
176-
#ifndef DISABLE_LOGGING
180+
#ifndef DISABLE_LOGGING
177181
if (LOG_LEVEL_NOTICE <= _level) {
178182
if (_showLevel) _logOutput->print("N: ");
179183
va_list args;
180184
va_start(args, msg);
181185
print(msg,args);
182186
}
183-
#endif
187+
#endif
184188
}
185189
/**
186190
* Output a trace message. Output message contains
187-
* Debug messages are printed out at l
188-
* loglevels >= LOG_LEVEL_VERBOSE
191+
* N: followed by original message
192+
* Trace messages are printed out at
193+
* loglevels >= LOG_LEVEL_TRACE
189194
*
190195
* \param msg format string to output
191196
* \param ... any number of variables
192197
* \return void
193198
*/
194199
template <class T> void trace(T msg, ...){
195-
#ifndef DISABLE_LOGGING
200+
#ifndef DISABLE_LOGGING
196201
if (LOG_LEVEL_TRACE <= _level) {
197202
if (_showLevel) _logOutput->print("T: ");
198203
va_list args;
199204
va_start(args, msg);
200205
print(msg,args);
201206
}
202-
#endif
203-
}
204-
207+
#endif
208+
}
209+
205210
/**
206-
* Output an verbose message. Output message contains
207-
* Debug messages are printed out at l
211+
* Output a verbose message. Output message contains
212+
* V: followed by original message
213+
* Debug messages are printed out at
208214
* loglevels >= LOG_LEVEL_VERBOSE
209215
*
210216
* \param msg format string to output
211217
* \param ... any number of variables
212218
* \return void
213219
*/
214220
template <class T> void verbose(T msg, ...){
215-
#ifndef DISABLE_LOGGING
221+
#ifndef DISABLE_LOGGING
216222
if (LOG_LEVEL_VERBOSE <= _level) {
217223
if (_showLevel) _logOutput->print("V: ");
218224
va_list args;
219225
va_start(args, msg);
220226
print(msg,args);
221227
}
222-
#endif
228+
#endif
223229
}
224-
230+
225231
private:
226232
void print(const char *format, va_list args);
227233
void print(const __FlashStringHelper *format, va_list args);
@@ -231,6 +237,3 @@ class Logging {
231237
extern Logging Log;
232238
#endif
233239

234-
235-
236-

examples/Log/Log.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void setup() {
2121
randomSeed(analogRead(0));
2222
// Pass log level, whether to show log level, and print interface.
2323
// Available levels are:
24-
// LOG_LEVEL_SILENT, LOG_LEVEL_FATAL, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, LOG_LEVEL_NOTICE, LOG_LEVEL_VERBOSE
24+
// LOG_LEVEL_SILENT, LOG_LEVEL_FATAL, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, LOG_LEVEL_NOTICE, LOG_LEVEL_TRACE, LOG_LEVEL_VERBOSE
2525
// Note: if you want to fully remove all logging code, uncomment #define DISABLE_LOGGING in Logging.h
2626
// this will significantly reduce your project size
2727

@@ -67,4 +67,4 @@ void loop() {
6767
Log.fatal ( "Log as Fatal with bool value : %T" CR , boolValue1);
6868
Log.verbose (F("Log as Verbose with bool value : %T" CR CR CR ), boolValue2);
6969
delay(5000);
70-
}
70+
}

keywords.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ Logging KEYWORD2 Logging library
3030
#######################################
3131
# Constants (LITERAL1)
3232
#######################################
33-
LOG_LEVEL_NOOUTPUT LITERAL1 Constants
34-
LOG_LEVEL_ERRORS LITERAL1 Constants
35-
LOG_LEVEL_INFOS LITERAL1 Constants
36-
LOG_LEVEL_DEBUG LITERAL1 Constants
33+
LOG_LEVEL_SILENT LITERAL1 Constants
34+
LOG_LEVEL_FATAL LITERAL1 Constants
35+
LOG_LEVEL_ERROR LITERAL1 Constants
36+
LOG_LEVEL_WARNING LITERAL1 Constants
37+
LOG_LEVEL_NOTICE LITERAL1 Constants
38+
LOG_LEVEL_TRACE LITERAL1 Constants
3739
LOG_LEVEL_VERBOSE LITERAL1 Constants
3840

0 commit comments

Comments
 (0)