log: print messages to stdout/sderr if running in console mode
PATCH v2 1/1 log: print messages to stdout/sderr if running in console mode
If conntrackd is running in console mode (i.e. in foreground) then we can print the log messages to stdout/stderr.
This eases the workflow for admins, since we condensate more info into the same terminal output.
Example:
% sudo conntrackd -C /etc/conntrackd.conf
WARNING: XXXX is an invalid interface
[Thu Oct 27 13:57:09 2016] (pid=7581) [notice] disabling internal cache [Thu Oct 27 13:57:09 2016] (pid=7581) [notice] disabling external cache [Thu Oct 27 13:57:09 2016] (pid=7581) [ERROR] can't open channel socket: No such device [Thu Oct 27 13:57:09 2016] (pid=7581) [ERROR] initialization failed
ERROR: conntrackd cannot start, please check the logfile for more info
---
v2: fix va_list arguments usage by using pointers where needed.
include/conntrackd.h | 1 + src/log.c | 67 +++++++++++++++++++++++++++++++++++--------------- src/main.c | 1 + 3 files changed, 49 insertions(+), 20 deletions(-)
include/conntrackd.h +1 -0
@@ -110,6 +110,7 @@ struct ct_conf {int filter_from_kernelspace;int event_iterations_limit;int systemd; +int running_mode;struct {int error_queue_length; } channelc;
src/log.c +47 -20
88 lines not on this page · raw message
src/main.c +1 -0
@@ -150,6 +150,7 @@ int main(int argc, char *argv[])switch (argv[i][1 ]) {case 'd' :set_operation_mode (&type,DAEMON , argv); +CONFIG (running_mode) =DAEMON ;break ;case 'c' :set_operation_mode (&type,REQUEST , argv);
Quoted 5 lines · Arturo Borrero Gonzalez
If conntrackd is running in console mode (i.e. in foreground) then we can print the log messages to stdout/stderr.
This eases the workflow for admins, since we condensate more info into the same terminal output.
Applied, thanks Arturo.
BTW, one comment:
Quoted 4 lines
Example:
% sudo conntrackd -C
/etc/conntrackd.conf
WARNING: XXXX is an invalid interface
Probably, we can now place this message via logging. I remember the problem is that logging is not yet initialized at that stage, but this should be easy to fix.
Quoted 5 lines
[Thu Oct 27 13:57:09 2016] (pid=7581) [notice] disabling internal cache [Thu Oct 27 13:57:09 2016] (pid=7581) [notice] disabling external cache [Thu Oct 27 13:57:09 2016] (pid=7581) [ERROR] can't open channel socket: No such device [Thu Oct 27 13:57:09 2016] (pid=7581) [ERROR] initialization failedERROR: conntrackd cannot start, please check the logfile for more info
And I guess this "ERROR: conntrackd cannot start, please review your configuration" can go into log message too.