[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [BusyBox] logger & syslogd: should they agree about date formats?
From:       Stewart Brodie <stewart.brodie () pace ! co ! uk>
Date:       2003-03-25 10:13:03
[Download RAW message or body]

(comments refer to the unstable repository in CVS, latest as of the date of
this message)

I am seeing various messages in the syslogd-generated log which contain two
dates, for example:

Jan  1 00:00:16 136 user.notice  1<0xe6><0x9c><0x88>  1 00:00:16 message ...

The problem here is that the date specification generated by logger has been
generated in Chinese using a UTF-8 encoding (month name shown in hex in the
string above), which syslogd then fails to recognise as a date (because it
doesn't match the strict tests in syslogd.c:logMessage) and hence generates
its own timestamp.

There are several things happening here and I'm not sure if any of them are
bugs, to be honest, but would like opinions on which behaviour is correct.

Firstly, syslogd is testing the message string using a hardwired idea of what
a date looks like.  (One possible way around this would be for it to use
strftime to generate the current date and then compare it against the start
of the message - although that gives it a tiny loophole at day rollovers :-)

Secondly, syslogd uses ctime and not strftime to generate the time string. 
ctime always produces English output, regardless of locale.  strftime will
use the correct locale, but only if syslogd does 'setlocale(LC_TIME, "")'
before calling strftime.

Thirdly, logger is at the mercy of the C library as to the format of the
timestamp that the syslog() generates.  glibc uses strftime; uClibc uses
ctime.

I suppose the question is does this matter?  It's just rather ugly that the
log file has half the messages with two dates in depending on whether or not
the calling process has called setlocale(LC_TIME, "") or not.

-- 
Stewart Brodie, Senior Software Engineer
Pace Micro Technology PLC
645 Newmarket Road
Cambridge, CB5 8PB, United Kingdom         WWW: http://www.pacemicro.com/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic