logger: show module name
This commit is contained in:
parent
041255e15f
commit
d449e31586
|
@ -3,6 +3,11 @@
|
|||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
//#define LOGGER_DISABLE_ALL // define this to disable all logging from this module
|
||||
|
||||
#define LOGGER_MODULE_NAME "l1rx"
|
||||
#include "logger.h"
|
||||
|
||||
#include "correlator.h"
|
||||
#include "preamble.h"
|
||||
#include "freq_est.h"
|
||||
|
@ -15,9 +20,6 @@
|
|||
|
||||
#include "utils.h"
|
||||
|
||||
//#define LOGGER_DISABLE_ALL // define this to disable all logging from this module
|
||||
#include "logger.h"
|
||||
|
||||
#define SYMBOL_BUFFER_SIZE 16384
|
||||
|
||||
#define HEADER_SIZE_BYTES 2
|
||||
|
|
|
@ -117,7 +117,7 @@ void logger_debug_message(const char *prefix, const char *fmt, va_list ap)
|
|||
free(p);
|
||||
}
|
||||
|
||||
void logger_log(int level, const char *format, ...)
|
||||
void logger_log(int level, const char *module_name, const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
|
@ -133,7 +133,7 @@ void logger_log(int level, const char *format, ...)
|
|||
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
strftime(timebuf, 32, "%Y-%M-%d %H:%M:%S.%%03d", localtime(&(tv.tv_sec)));
|
||||
strftime(timebuf, 32, "%Y-%m-%d %H:%M:%S.%%03d", localtime(&(tv.tv_sec)));
|
||||
snprintf(timebuf2, 32, timebuf, tv.tv_usec/1000);
|
||||
|
||||
if(level >= LVL_DUMP) {
|
||||
|
@ -175,9 +175,9 @@ void logger_log(int level, const char *format, ...)
|
|||
}
|
||||
|
||||
if(logger_use_colors) {
|
||||
sprintf(prefixbuf, "%s [%s%s%s]", timebuf2, prefixcolor, prefixtext, LOGGER_COLOR_NONE);
|
||||
sprintf(prefixbuf, "%s [%s%s%s %-8s]", timebuf2, prefixcolor, prefixtext, LOGGER_COLOR_NONE, module_name);
|
||||
} else {
|
||||
sprintf(prefixbuf, "%s [%s]", timebuf2, prefixtext);
|
||||
sprintf(prefixbuf, "%s [%s %-8s]", timebuf2, prefixtext, module_name);
|
||||
}
|
||||
|
||||
va_start(argptr, format);
|
||||
|
|
|
@ -41,10 +41,14 @@ void logger_shutdown(void);
|
|||
void logger_enable_colors(int enable);
|
||||
void logger_set_verbosity(int verbosity);
|
||||
|
||||
void logger_log(int level, const char *format, ...);
|
||||
void logger_log(int level, const char *module_name, const char *format, ...);
|
||||
|
||||
#ifndef LOGGER_MODULE_NAME
|
||||
#define LOGGER_MODULE_NAME "undef"
|
||||
#endif
|
||||
|
||||
#ifndef LOGGER_DISABLE_ALL
|
||||
#define LOG(level, ...) logger_log(level, __VA_ARGS__)
|
||||
#define LOG(level, ...) logger_log(level, LOGGER_MODULE_NAME, __VA_ARGS__)
|
||||
#else
|
||||
#define LOG(level, ...) {}
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOGGER_MODULE_NAME "main"
|
||||
#include "logger.h"
|
||||
#include "options.h"
|
||||
#include "jsonlogger.h"
|
||||
|
|
Loading…
Reference in a new issue