]> Cypherpunks repositories - gostls13.git/commit
log/syslog: correct message format
authorJohn Graham-Cumming <jgc@jgc.org>
Tue, 27 Nov 2012 15:21:43 +0000 (10:21 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 27 Nov 2012 15:21:43 +0000 (10:21 -0500)
commit4228eb791523d4641b5c1c2434b347f596f6760e
treeb37e1c42bdd05484a1f92d2a985c9e0c752f7df0
parent908e1b5ea1fa09227b52c9818b6abb6c21ae3261
log/syslog: correct message format

The syslog implementation was not correctly implementing the
traditional syslog format because it had a confused notion of
'priority'.  syslog priority is not a single number but is, in
fact, the combination of a facility number and a severity. The
previous Go syslog implementation had a single Priority that
appeared to be the syslog severity and no way of setting the
facility.  That meant that all syslog messages from Go
programs appeared to have a facility of 0 (LOG_KERN) which
meant they all appeared to come from the kernel.

Also, the 'prefix' was in fact the syslog tag (changed the
internal name for clarity as the term tag is more widely used)
and the timestamp and hostname values were missing from
messages.

With this change syslog messages are generated in the correct
format with facility and severity combined into a priority,
the timestamp in RFC3339 format, the hostname, the tag (with
the PID in [] appened) and the message.

The format is now:

   <PRI>1 TIMESTAMP HOSTNAME TAG[PID]: MSG

The TIMESTAMP, HOSTNAME and PID fields are filled in
automatically by the package. The TAG and the MSG are supplied
by the user. This is what rsyslogd calls TraditionalFormat and
should be compatible with multiple systems.

R=rsc, jgc, 0xjnml, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/6782118
src/pkg/log/syslog/syslog.go
src/pkg/log/syslog/syslog_test.go