Merge branch '34-logging-should-include-the-id-of-the-disc-that-is-being-served' into 'develop'
add a log_context, a string output as part of any log message Closes #34 See merge request open-source/flexnbd-c!34
This commit is contained in:
3
debian/changelog
vendored
3
debian/changelog
vendored
@@ -1,8 +1,9 @@
|
|||||||
flexnbd (0.1.8) UNRELEASED; urgency=medium
|
flexnbd (0.1.8) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* Set TCP keepalive on sockets so broken connections are reaped (#33, !33)
|
* Set TCP keepalive on sockets so broken connections are reaped (#33, !33)
|
||||||
|
* Add a context to logs to make debugging problems easier (#34, !34)
|
||||||
|
|
||||||
-- James Carter <james.carter@bytemark.co.uk> Wed, 10 Jan 2018 13:57:10 +0000
|
-- James Carter <james.carter@bytemark.co.uk> Thu, 11 Jan 2018 10:05:35 +0000
|
||||||
|
|
||||||
flexnbd (0.1.7) stable; urgency=medium
|
flexnbd (0.1.7) stable; urgency=medium
|
||||||
|
|
||||||
|
@@ -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__)
|
||||||
|
@@ -79,6 +79,9 @@ struct proxier* proxy_create(
|
|||||||
out->req.buf = xmalloc( NBD_MAX_SIZE );
|
out->req.buf = xmalloc( NBD_MAX_SIZE );
|
||||||
out->rsp.buf = xmalloc( NBD_MAX_SIZE );
|
out->rsp.buf = xmalloc( NBD_MAX_SIZE );
|
||||||
|
|
||||||
|
log_context = xmalloc( strlen(s_upstream_address) + strlen(s_upstream_port) + 2 );
|
||||||
|
sprintf(log_context, "%s:%s", s_upstream_address, s_upstream_port);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -78,6 +78,8 @@ struct server * server_create (
|
|||||||
NULLCHECK( out->close_signal );
|
NULLCHECK( out->close_signal );
|
||||||
NULLCHECK( out->acl_updated_signal );
|
NULLCHECK( out->acl_updated_signal );
|
||||||
|
|
||||||
|
log_context = s_file;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user