[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Logging cf Reporting = Friday Filosofical Finking

> > Is logging an unpopular package?
> I've been writing Python applications for 20 years.  On several
> occasions, I've sat down determined to use it.  After a frustrating
> half a day or so trying to get it to do what I want (and failing),
> I've always given up and gone back to writing my own throw-away
> logging functions (typically containing a dozen or so lines of code).

I'm with Grant. I only broke down recently because that's what's used
at work and I need to eat. I log *a lot* and always felt it solved
problems I never had. For example, I never needed to log to syslog,
include the current thread id in my log messages, or to have multiple
simultaneous active handlers. (Though I can understand that some
people will want all this stuff.) A simple logger with ISO-8601
timestamps and a strftime-ish-formatted message was all I ever needed.
Performance of initial versions was also abysmal, which meant I
couldn't log at the volumes I needed to in real-time-ish applications.
My current mini-frustration is that you can't cleanly log with
subsecond resolution *and* include the timezone in the timestamp. You
wind up writing a special Formatter to do that. The logging module was
introduced at the same time as datetime (Python 2.3 timeframe [1],
around 2003 - plenty of time since then to have introduced a breaking
change to use datetime objects under the covers, if one was
necessary). There is really no good reason the logging package was
ever shackled to the tuple output of time.{localtime,gmtime} in the
first place. Those are just thin wrappers around the corresponding
stdlib functions [2] which were written in the 1980s or earlier [3].


[1] https://www.python.org/doc/versions/
[2] https://www.freebsd.org/cgi/man.cgi?query=localtime&apropos=0&sektion=0&manpath=FreeBSD+12.0-RELEASE+and+Ports&arch=default&format=html
[3] https://svnweb.freebsd.org/base/head/share/misc/bsd-family-tree?view=co