[sheepdog] [PATCH] logger: add date and time to log messages even if an output is stdout

Hitoshi Mitake h.mitake at gmail.com
Thu Dec 20 16:13:54 CET 2012


At Thu, 20 Dec 2012 20:26:16 +0800,
Liu Yuan wrote:
> 
> On 12/20/2012 05:48 PM, Hitoshi Mitake wrote:
> > +	if (!la) {
> > +		time_t t = time(NULL);
> > +		struct tm tm;
> > +		gmtime_r(&t, &tm);
> > +
> > +		snprintf(p, size, "%s %02d %02d:%02d:%02d ", month(tm.tm_mon),
> > +			tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
> > +		p += strlen(p);
> > +	}
> 
> Use strftime() as in log_syslog() isn't easier and then no need to call
> month()?
> 

strftime() is suitable. Thanks for your advice.
BTW, even if the output of vprintf() is syslog, printing time on heads
of messages is done by log_syslog().

How do you think about printing time in dolog() for all output types?

Thanks,
Hitoshi



More information about the sheepdog mailing list