mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-22 06:27:51 +00:00
Respect LOG_LEVEL_SILENT
This commit is contained in:
parent
8fca6b5c5e
commit
0bf366f789
42
log.c
42
log.c
@ -37,29 +37,31 @@ void logMessage(int level, const char *file, unsigned int line, const char *func
|
|||||||
|
|
||||||
void vlogMessage(int level, const char *file, unsigned int line, const char *function, const char *fmt, va_list ap)
|
void vlogMessage(int level, const char *file, unsigned int line, const char *function, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
strbuf b = strbuf_alloca(8192);
|
if (level != LOG_LEVEL_SILENT) {
|
||||||
strbuf_sprintf(b, "%s:%u:%s() ", file ? trimbuildpath(file) : "NULL", line, function ? function : "NULL");
|
strbuf b = strbuf_alloca(8192);
|
||||||
strbuf_vsprintf(b, fmt, ap);
|
strbuf_sprintf(b, "%s:%u:%s() ", file ? trimbuildpath(file) : "NULL", line, function ? function : "NULL");
|
||||||
|
strbuf_vsprintf(b, fmt, ap);
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
int alevel = ANDROID_LOG_UNKNOWN;
|
int alevel = ANDROID_LOG_UNKNOWN;
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case LOG_LEVEL_FATAL: alevel = ANDROID_LOG_FATAL; break;
|
case LOG_LEVEL_FATAL: alevel = ANDROID_LOG_FATAL; break;
|
||||||
case LOG_LEVEL_ERROR: alevel = ANDROID_LOG_ERROR; break;
|
case LOG_LEVEL_ERROR: alevel = ANDROID_LOG_ERROR; break;
|
||||||
case LOG_LEVEL_INFO: alevel = ANDROID_LOG_INFO; break;
|
case LOG_LEVEL_INFO: alevel = ANDROID_LOG_INFO; break;
|
||||||
case LOG_LEVEL_WARN: alevel = ANDROID_LOG_WARN; break;
|
case LOG_LEVEL_WARN: alevel = ANDROID_LOG_WARN; break;
|
||||||
case LOG_LEVEL_DEBUG: alevel = ANDROID_LOG_DEBUG; break;
|
case LOG_LEVEL_DEBUG: alevel = ANDROID_LOG_DEBUG; break;
|
||||||
}
|
}
|
||||||
__android_log_print(alevel, "servald", "%s", strbuf_str(b));
|
__android_log_print(alevel, "servald", "%s", strbuf_str(b));
|
||||||
#endif
|
#endif
|
||||||
const char *levelstr = "UNKNOWN";
|
const char *levelstr = "UNKNOWN";
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case LOG_LEVEL_FATAL: levelstr = "FATAL"; break;
|
case LOG_LEVEL_FATAL: levelstr = "FATAL"; break;
|
||||||
case LOG_LEVEL_ERROR: levelstr = "ERROR"; break;
|
case LOG_LEVEL_ERROR: levelstr = "ERROR"; break;
|
||||||
case LOG_LEVEL_INFO: levelstr = "INFO"; break;
|
case LOG_LEVEL_INFO: levelstr = "INFO"; break;
|
||||||
case LOG_LEVEL_WARN: levelstr = "WARN"; break;
|
case LOG_LEVEL_WARN: levelstr = "WARN"; break;
|
||||||
case LOG_LEVEL_DEBUG: levelstr = "DEBUG"; break;
|
case LOG_LEVEL_DEBUG: levelstr = "DEBUG"; break;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "%s: %s\n", levelstr, strbuf_str(b));
|
||||||
}
|
}
|
||||||
fprintf(stderr, "%s: %s\n", levelstr, strbuf_str(b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *trimbuildpath(const char *path)
|
const char *trimbuildpath(const char *path)
|
||||||
|
Loading…
Reference in New Issue
Block a user