From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from feline.systems ([99.23.220.214]) by ur; Wed Feb 10 00:03:30 EST 2016 Date: Wed, 10 Feb 2016 00:03:23 -0500 From: BurnZeZ@feline.systems To: 9front@9front.org Subject: syslog(2) change Message-ID: <1270b9585a3e327733049d87e8a08103@utsuho.znet> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-kmeazzzirgdvvbvciyjwqshjeg" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: optimized flexible deep-learning controller This is a multi-part message in MIME format. --upas-kmeazzzirgdvvbvciyjwqshjeg Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Currently, syslog() prints sysname, date/time, and fmt. Check out the diff and tell me if I'm just being dumb. Sample before/after lines... cirno Feb 9 20:38:55 Hung up on 8.8.8.8; claimed to be fbi.gov 1455068335 cirno Hung up on 8.8.8.8; claimed to be fbi.gov Nobody wants this stupid crap where you have to try to recall which timezone(s) a machine is/was in. Also, with this change it's easy to plot out occurrences of some log string over time, as you don't have to do any date string conversions (useful when trying to track down bugs that don't present themselves frequently). The only con I can think of is that you'll need to use date(1) to convert the timestamp if you want your date string, but hey, at least the timestamp isn't ambiguous. --upas-kmeazzzirgdvvbvciyjwqshjeg Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit diff -r 94c649383b95 sys/man/2/perror --- a/sys/man/2/perror Tue Feb 09 16:24:41 2016 -0500 +++ b/sys/man/2/perror Tue Feb 09 19:54:00 2016 -0500 @@ -36,8 +36,8 @@ .I Logname must contain no slashes. The message is a line with several fields: +seconds since the epoch; the name of the machine writing the message; -the date and time; the message specified by the .IR print (2) format diff -r 94c649383b95 sys/src/libc/9sys/syslog.c --- a/sys/src/libc/9sys/syslog.c Tue Feb 09 16:24:41 2016 -0500 +++ b/sys/src/libc/9sys/syslog.c Tue Feb 09 19:54:00 2016 -0500 @@ -43,7 +43,7 @@ syslog(int cons, char *logname, char *fmt, ...) { char buf[1024]; - char *ctim, *p; + char *p; va_list arg; int n; Dir *d; @@ -92,11 +92,7 @@ return; } - ctim = ctime(time(0)); - p = buf + snprint(buf, sizeof(buf)-1, "%s ", sysname()); - strncpy(p, ctim+4, 15); - p += 15; - *p++ = ' '; + p = buf + snprint(buf, sizeof(buf)-1, "%ld %s ", time(0), sysname()); errstr(err, sizeof err); va_start(arg, fmt); p = vseprint(p, buf+sizeof(buf)-1, fmt, arg); --upas-kmeazzzirgdvvbvciyjwqshjeg--