9front - general discussion about 9front
 help / color / mirror / Atom feed
* syslog(2) change
@ 2016-02-10  5:03 BurnZeZ
  2016-02-10  5:08 ` [9front] " Devon H. O'Dell
  2016-02-10  5:41 ` arisawa
  0 siblings, 2 replies; 17+ messages in thread
From: BurnZeZ @ 2016-02-10  5:03 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 757 bytes --]

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.

[-- Attachment #2: Type: text/plain, Size: 1057 bytes --]

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);

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-02-11  3:02 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-10  5:03 syslog(2) change BurnZeZ
2016-02-10  5:08 ` [9front] " Devon H. O'Dell
2016-02-10  5:41 ` arisawa
2016-02-10 12:14   ` BurnZeZ
2016-02-10 13:52     ` arisawa
2016-02-10 16:15       ` stanley lieber
2016-02-10 20:25         ` BurnZeZ
2016-02-10 20:28           ` sl
2016-02-10 20:57             ` Julius Schmidt
2016-02-10 21:06               ` sl
2016-02-10 21:08               ` Kurt H Maier
2016-02-10 21:22                 ` Devon H. O'Dell
2016-02-10 21:24                   ` sl
2016-02-10 22:41             ` BurnZeZ
2016-02-11  3:02               ` arisawa
2016-02-10 16:06     ` Kurt H Maier
2016-02-10 20:24       ` BurnZeZ

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).