Opened 6 years ago

Last modified 2 years ago

#9494 new defect

Remove gratuitous newlines from log messages?

Reported by: grarpamp Owned by:
Priority: Low Milestone: Tor: unspecified
Component: Core Tor/Tor Version: Tor: 0.2.3.25
Severity: Normal Keywords: tor-relay logging easy
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

These log entries (debug, domains) are either

  • missing facility

t [notice] Tor v0.2.3.25 (git-r) running on o.
t [notice] Tor can't help you if you use it wrong! Learn how to
t [notice] Read configuration file "/.../torrc".
t [notice] Initialized libevent version 2.0.21-stable using method
t [notice] Opening Socks listener on 127.0.0.1:9051
t [notice] Opening Control listener on 127.0.0.1:9050
t [warn] Fixing permissions on directory /.../tor

  • missing time, level and facility, and probably need one-lined

0 create
64 created
6494 relay

(644 relayed)
(6494 delivered)

50 destroy

Child Tickets

Change History (11)

comment:1 Changed 6 years ago by nickm

I don't understand this mesage. By "missing facility", do you mean, "doesn't have a function name at the beginning?" That's okay. We don't require every log message to have a function name. Or did you mean something else?

The "missing time, level, and facility" ones are lines 2...N of a multi-line log message generated by dumpstats, I think.

comment:2 Changed 6 years ago by grarpamp

In the syslog world we call it 'facility.level'. Tor calls it '[domain]severity'.
Yes, I dumped it with usr1.

Each new line (termed with '\n', or the close of the call I think) should be
prefixed with time, level and domain, if configured to show that, which they were...

log debug stdout
logmessagedomains 1

but they didn't... in part, in two separate cases.

Also, I just tried sending debug to syslog and got...

Aug 16 00:00:00 <daemon.notice> host Tor[pid]: message

While the Tor's 'severity' might match up linearly with the levels of say
FreeBSD's syslog below (I didn't check Tor's name number map / ordering)...

emerg, alert, crit, err, warning, notice, info, debug

the 'domains' do not match facilities of course. So in addition to
the prefixing issue above, I think when syslog is destination,
'logmessagedomains 1' should print themselves in syslog too.
Might as well add a 'syslogfacility (default: daemon)' option
too so folks can send it to localN, etc.
I'm pretty sure 'warn/WARN' is deprecated for 'warning/WARNING',
posix may say about that, might be OS dependant too.

comment:3 Changed 6 years ago by nickm

Keywords: tor-relay added
Milestone: Tor: 0.2.4.x-finalTor: 0.2.5.x-final
Priority: normalminor

Hm. If there's an actual standard here, we can consider moving towards it in 0.2.5, I guess. Right now, I don't think we purport to have our log messages follow any particular standard.

The problem with adding domains to the early log messages in 0.2.4 is that those messages are emitted before we've actually become configured and learned that LogMessageDoamains is supposed to be set. This is tricky enough to change that I think 0.2.4 can go without it.

(Is the relevant standard online anywhere?)

comment:4 Changed 6 years ago by grarpamp

These two deprecate 'warn' for not being per spec:
freebsd: /usr/include/syslog.h
linux: http://linux.die.net/man/5/syslog.conf
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/syslog.h.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/syslog.html

I never looked for a spec regarding syslog style head of line tagging.

The -usr1 info format can be fixed.
Nicely single line in syslog, but is far too wide, and domain=1 is missing
(from all syslog).
Multi line in stdout, only the first line is stamped (and optionally domain'ed).

Before configured... very early on, sure, it could be harder to tweak. Though
cmdline '--logdomains 1' produces no difference there at the moment.

comment:5 Changed 5 years ago by nickm

Milestone: Tor: 0.2.5.x-finalTor: 0.2.???

comment:6 Changed 3 years ago by teor

Milestone: Tor: 0.2.???Tor: 0.3.???

Milestone renamed

comment:7 Changed 2 years ago by nickm

Keywords: tor-03-unspecified-201612 added
Milestone: Tor: 0.3.???Tor: unspecified

Finally admitting that 0.3.??? was a euphemism for Tor: unspecified all along.

comment:8 Changed 2 years ago by nickm

Keywords: tor-03-unspecified-201612 removed

Remove an old triaging keyword.

comment:9 Changed 2 years ago by nickm

Resolution: worksforme
Severity: Normal
Status: newclosed
Summary: Log fix facility and linesRemove gratuitous newlines from log messages?

comment:10 Changed 2 years ago by nickm

Resolution: worksforme
Status: closedreopened

comment:11 Changed 2 years ago by nickm

Keywords: logging easy added
Status: reopenednew

The take-out-the-newlines part shouldn't be too hard...

Note: See TracTickets for help on using tickets.