9front - general discussion about 9front
 help / color / mirror / Atom feed
From: BurnZeZ@feline.systems
To: 9front@9front.org
Subject: syslog(2) change
Date: Wed, 10 Feb 2016 00:03:23 -0500	[thread overview]
Message-ID: <1270b9585a3e327733049d87e8a08103@utsuho.znet> (raw)

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

             reply	other threads:[~2016-02-10  5:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-10  5:03 BurnZeZ [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1270b9585a3e327733049d87e8a08103@utsuho.znet \
    --to=burnzez@feline.systems \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).