coova / coova-chilli

CoovaChilli is an open-source software access controller for captive portal hotspots.
Other
520 stars 260 forks source link

some debug messages still show on syslog #119

Open vfxcode opened 8 years ago

vfxcode commented 8 years ago

Some debug messages still apear on syslog (OpenWRT) from at least: src/main-opt.c src/main-proxy.c src/main-radsec.c src/ssl.c

Seems like some syslog(LOG_DEBUG, functions are not wrapped with #if(debug) or if (_options.debug) . Which one is applicable I suspect is subject to discussion.

Its annoying and fills the (quite small) syslog ring buffer very fast.

Attached is a sample log samplelog.txt

wlanmac commented 8 years ago

+1 Yes, it was a consequence of moving to syslog. All debug syslog should be wrapped at least with _options.debug.

vfxcode commented 8 years ago

Ok I will fork and start the wrapping process at least for the ones I come across. I will issue pull requests as I work....

vfxcode commented 8 years ago

Wouldn't setlogmask() be a better choice instead of wrapping the syslog() calls with if s?

gbaligh commented 8 years ago

I thinks that we have to create a new preprocessor macro to avoid repeating the same code:

#if TRACE_SYSLOG
#define CHILLI_LOG(level, fmt, args...) if (_options.debug) syslog(level, fmt, ##args)
#elif TRACE
#define CHILLI_LOG(level, fmt, args...) if (_options.debug) fprintf(stderr, "[" #level "] - " fmt "\n", ##args)
#else
#define CHILLI_LOG(level, fmt, args...)
#endif

and in the configure.ac, we can add a new configuration --with-trace=syslog : to activate syslog() use --with-trace : to use fprintf() --without-trace : deactivate traces

We can change the macro to do what ever we want: log to file, log to socket, ...

What do you thinks guys ?

vfxcode commented 8 years ago

We could do that as well... but I think wrapping syslog() in an if () is unnecessary if setlogmask() is used as well. Either one or the other.

sevan commented 8 years ago

Coova was previously using macros for the logging which I worked through & ripped out. Try to solve a problem without macros, you're less likely to make mistakes which go undetected eg through the switch back at the last round, it was discovered that there were instance where the parameter list contained the wrong data format identifiers which were never flagged up as a macro.