add a log_context, a string output as part of any log message
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
pthread_key_t cleanup_handler_key;
|
pthread_key_t cleanup_handler_key;
|
||||||
|
|
||||||
int log_level = 2;
|
int log_level = 2;
|
||||||
|
char *log_context = "";
|
||||||
|
|
||||||
void error_init(void)
|
void error_init(void)
|
||||||
{
|
{
|
||||||
|
@@ -21,6 +21,9 @@ extern int log_level;
|
|||||||
/* set up the error globals */
|
/* set up the error globals */
|
||||||
void error_init(void);
|
void error_init(void);
|
||||||
|
|
||||||
|
/* some context for the overall process that appears on each log line */
|
||||||
|
extern char *log_context;
|
||||||
|
|
||||||
|
|
||||||
void exit_err( const char * );
|
void exit_err( const char * );
|
||||||
|
|
||||||
@@ -92,7 +95,7 @@ uint64_t monotonic_time_ms(void);
|
|||||||
|
|
||||||
#define levstr(i) (i==0?'D':(i==1?'I':(i==2?'W':(i==3?'E':'F'))))
|
#define levstr(i) (i==0?'D':(i==1?'I':(i==2?'W':(i==3?'E':'F'))))
|
||||||
|
|
||||||
#define myloglev(level, msg, ...) mylog( level, "%"PRIu64":%c:%d %p %s:%d: "msg"\n", monotonic_time_ms(), levstr(level), getpid(),pthread_self(), __FILE__, __LINE__, ##__VA_ARGS__ )
|
#define myloglev(level, msg, ...) mylog( level, "%"PRIu64":%c:%d %p %s %s:%d: "msg"\n", monotonic_time_ms(), levstr(level), getpid(),pthread_self(), log_context, __FILE__, __LINE__, ##__VA_ARGS__ )
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# define debug(msg, ...) myloglev(0, msg, ##__VA_ARGS__)
|
# define debug(msg, ...) myloglev(0, msg, ##__VA_ARGS__)
|
||||||
|
Reference in New Issue
Block a user