Closed dhimmel closed 7 years ago
I can assure you errorhandler doesn't do anything of the sort, check the code, there's not much to it:
https://github.com/Simplistix/errorhandler/blob/master/errorhandler/__init__.py
So, having had a look at greenelab/manubot#2, you're hitting the confusing behaviour of the Python logging library as documented here:
https://docs.python.org/2/library/logging.html#logging.basicConfig
Previously, you were doing no setup, so your first call to logging.(error|warning|etc)
called basicConfig
, but that does nothing as once ErrorHandler()
is installed, the root logger already has a handler.
Moral of the story: always explicitly configure your log handlers ;-)
Moral of the story: always explicitly configure your log handlers ;-)
Thanks. Just to make sure I understand the recommendation, it's fine to call logging.warning()
directly in modules to log to the root logger. However, for functions / scripts that run a program, they should explicitly configure how the root logger is handled?
Fine to call logging.warning
, but make sure you configure handlers first ;-)
Thanks @cjw296. Keep up the great work!
Great package! It does exactly what I needed. This repo took me a while to find, but it's an honor to be the first user to star it! The use case it solves seems like it should be pretty common, especially with the growing use of continuous integration builds. I answered a StackOverflow question with this package.
I'm adding
errorhandler
to our project in https://github.com/greenelab/manubot/pull/2. One thing that confused me at first was that adding error handler suppressed the default logging to stderr. I'm not sure whether this is intentional or a bug. Anyways, here's the code I used to get the stderr logging back:Is this the simplest workaround?