22 #define LOG_BUF_SIZE 128
24 static const char * _logLevel2Name[6] =
26 "TRCE",
"DBUG",
"INFO",
"WARN",
"ERRO",
"FATL"
29 static bool _logEnabled =
true;
33 #define TIME_CHARS_S "10"
36 static char _prevBuf[LOG_BUF_SIZE - TIME_CHARS];
37 static bool _repeat =
false;
42 if (!_logEnabled)
return;
43 if (level < _logLevel)
return;
44 if (level < mod->level)
return;
46 char logbuf[LOG_BUF_SIZE];
48 l = sprintf(logbuf,
"%" TIME_CHARS_S
"u [%s] %s - %s",
_logTime(), _logLevel2Name[level], msg, mod->name);
51 if (strncmp(logbuf + TIME_CHARS, _prevBuf, LOG_BUF_SIZE - TIME_CHARS) == 0) {
53 _logOut(level,
"... Last line repeats, suppressed");
59 memcpy(_prevBuf, logbuf + TIME_CHARS, LOG_BUF_SIZE - TIME_CHARS);
72 l = vsprintf(buf, fmt, va);
75 _logWriteIntr(mod, level, buf);
uint32_t _logTime()
Stub function, which should return the current time in seconds, since whatever.
void logEnable(bool enable)
Enable logging.
void _logWrite(LogModInfo *mod, LogLevel level, const char *msg,...)
Write a logging statement.
#define LOG_LEVEL_DEFAULT
The default logging level.
void logSetGlobalLevel(LogLevel level)
Set the global log level.
void _logOut(LogLevel level, char *logLine)
External dependency function.
Implements a generic logger facility.