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

Tito farmatito at tiscali.it
Sun Sep 3 19:14:25 UTC 2006


On Sunday 3 September 2006 20:36, you wrote:
> On Sunday 03 September 2006 20:02, Tito wrote:
> > > I prefer:
> > > 
> > > 	bb_logmode = LOGMODE_BOTH;
> > > 	...
> > > 	xopen(...); /* will output error to stderr & to syslog */
> > 
> > So you will need to reset this multiple times in the same app:
> > 
> > bb_logmode = LOGMODE_BOTH;
> > msg(a)
> > bb_logmode = LOGMODE_*;
> > msg(b)
> > bb_logmode = LOGMODE_BOTH;
> > 
> > etc.
> > 
> > maybe a size increase!?!
> 
> Yes, mighty 1 (one) instruction per store. Yeah, tragedy...
> 
> BTW, this particular example doesn't really need switching:
> 
> bb_logmode = LOGMODE_BOTH;
> msg(a);
> /* not needed: bb_logmode = LOGMODE_STDIO; */
> printf(b);
> /* not needed: bb_logmode = LOGMODE_BOTH; */
> ...
> 
> > I can agree on something like this for
> > int bb_facility = LOG_USER; (or LOG_DAEMON)
> > as this will be set just once per app, but
> > logmode maybe could change multiple times?
> 
> ...which is not a problem.

;-)

So, then go for it!
Maybe you can use this snippet of code for inspiration,
so at least my work wasn't a total waste of time.

int bb_facility = LOG_USER;


{
	va_list p;
	va_list p2;
	
	va_start(p, fmt);
	va_copy(p2, p);
	/* bb_err_msg stuff here */
	openlog(bb_applet_name, LOG_PID | LOG_CONS | LOG_NOWAIT, bb_facility);
	vsyslog(LOG_ERR, fmt, p2);
	if (ENABLE_FEATURE_CLEAN_UP) closelog();
	va_end(p);
	va_end(p2);
}

Ciao,
Tito
> --
> vda
> 



More information about the busybox mailing list