[RFC] make bb_[p]error_msgXXXX() functions able to direct output to syslog

Tito farmatito at tiscali.it
Sun Sep 3 15:01:22 UTC 2006


On Sunday 3 September 2006 15:52, Bernhard Fischer wrote:
> On Sun, Sep 03, 2006 at 02:39:55PM +0200, Denis Vlasenko wrote:
> >Hi,
> >
> >I worked on zcip (http://bugs.busybox.net/view.php?id=1005)
> >and in the process I fixed inconsistent use of syslog and bb_[p]error
> >functions.
> 
> >The solution which seems ok to me is to make bb_[p]error
> >syslog aware. That is, we need a global flag variable which
> >says "direct all bb_[p]error output to syslog (because
> >we are daemonized and there is no usable stdout/err)"
> >
> >Minor problem is how to select syslog level, but it isn't
> >that serious.
> >
> >Any objections?
> 
> No objection from my part. It would be nice if we can optionally feed
> the messages to both syslog and stderr. Recently a tee() was added in
> linux, so it would be nice if we could optionally use that
> infrastructure for the case where we want errors to go both to syslog
> and stderr.
> 
> Thoughts?
Hi,
There is bb_syslog + sulogin cleanup  patch pending and waiting for
 rob's review that maybe is interesting in this case:

         void bb_msg_and_syslog(int level, const char *fmt, ...)

	This function opens a connection to the system logger for a  program.
	The facility value is set through a global variable bb_facility as it 
	is changed just one time per applet and so we spare one argument.
	it then generates a log message and closes the descriptor
	if ENABLE_FEATURE_CLEAN_UP is set.
	The function generates also a message:
			if level is: LOG_INFO, LOG_NOTICE
							the message will not contain the applet's name and 
							goes to stdout;
			if level is:  LOG_DEBUG (only if CONFIG_DEBUG is set), LOG_WARNING 
							the message will contain the applet's name and 
							goes to stderr;
			if level is: LOG_ERR, LOG_CRIT, LOG_ALERT, LOG_EMERG
							the message will contain the applet's name and 
							goes to stderr, after printing this message 
							the progam will exit with a return value of EXIT_FAILURE.

	You can disable messages by adding LOG_ONLY (100) to the other LOG_* values.

	So by choosing an appropriate level value we can influence the behaviour
	of the function.


The posted patch needs two minor fixes if there is some interest i can rediff and 
repost it.

Ciao,
Tito
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bb_syslog.c
Type: text/x-csrc
Size: 2050 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060903/f430a86e/attachment-0002.c 


More information about the busybox mailing list