On Fri, 22 Nov 2013, Allan Wind wrote:

> On 2013-11-22 13:46:50, Yaroslav Halchenko wrote:
> > what about making it even better:

> > formatter = logging.Formatter("%(name)s[%(process)d]: %(levelname)-7s 
> > %(message)s")

> > so we report the pid as well, stay together with the name while still 
> > keeping
> > indentation for the levelname conssitent for easier visual parsing.  you can
> > try attached script to "play" with it.. it should look like

> Yeah, it's nice touch to include the pid.  I would still suggest 
> using the syslog level instead of encoding it into the message 
> part.

> At work we filter on priority and include that the level as a 
> tagged field like this with syslog-ng:

> template t_message {
>       template("$ISODATE $HOST ${MSGHDR}priority=$PRIORITY $MSG\n");
>       template_escape(no);
> };

well -- is that a part of any convention (besides at your work? ;-) )
I do not see in my logs any priority= listed while some other daemons do
prepend with level:

$> zgrep -i warning /var/log/daemon.log*
/var/log/daemon.log:May 15 13:39:32 washoe named[13929]: Warning: 
'empty-zones-enable/disable-empty-zone' not set: disabling RFC 1918 empty zones
/var/log/daemon.log:May 15 16:05:23 washoe named[3141]: Warning: 
'empty-zones-enable/disable-empty-zone' not set: disabling RFC 1918 empty zones
/var/log/daemon.log:Jun 18 06:33:55 washoe named[9888]: Warning: 
'empty-zones-enable/disable-empty-zone' not set: disabling RFC 1918 empty zones
/var/log/daemon.log:Oct  3 21:41:56 washoe named[19418]: Warning: 
'empty-zones-enable/disable-empty-zone' not set: disabling RFC 1918 empty zones

$> zgrep -i warning /var/log/daemon.log* | head
/var/log/daemon.log:Nov 17 11:11:45 novo ddclient[5539]: WARNING:  file 
/var/cache/ddclient/ddclient.cache, line 3: Invalid Value for keyword 'ip' = ''
...


> so we would end with messages like this:

> Nov 22 13:45:58 novo fail2ban[6554]: priority=info INFO    info msg kjasdhfk 
> jasdh fkjasdh fkjasdh fkjsdh f 
> laksdjflkasjdflkajsdklfjasdlkfjaslkdjflaskdjflkasdjfklasdjfk

moreover for as simple as downcasing the loglevel in priority=info would
require a bit deeper customization of the formatter which I would prefer to
avoid at this point.

So I guess for now I will submit a PR upstream (to myself and others) for
discussion with the change I have suggested.

-- 
Yaroslav O. Halchenko, Ph.D.
http://neuro.debian.net http://www.pymvpa.org http://www.fail2ban.org
Senior Research Associate,     Psychological and Brain Sciences Dept.
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to