Use logging
from standard library
#398
Replies: 6 comments 1 reply
-
sounds good to me as long as we can still get timestamps and weave the logger into the helpers? Also, we need to retain the snarky and insulting messages! haha |
Beta Was this translation helpful? Give feedback.
-
The nice thing about the standard logging module is that it allows you much more fine grained control over the log messages. You can keep logging all messages, from anywhere in the library, but the user of the library gets more control how and where the messages are going. It is not necessary for the library to provide timestamps as they can be included by the handler. The default line format does not include the timestamp, but it is easily added. It might be useful to provide a helper function that sets up the logging module similar to the current format so those who want the I'll see if I can whip up a draft pull request for the |
Beta Was this translation helpful? Give feedback.
-
@jtwhite79 what versions of Python should be supported? The travis config suggests Python versions 2.7, 3.5, 3.6 and 3.7 are used for testing, but the appveyor config suggests only Python 3.7 is tested. Also, |
Beta Was this translation helpful? Give feedback.
-
I think 3.7+ is fine. We are really only using github actions anymore.... |
Beta Was this translation helpful? Give feedback.
-
Sounds like a solid plan to me @Hugovdberg. Thanks for having a dig into this. |
Beta Was this translation helpful? Give feedback.
-
Hi @Hugovdberg, are you still interested in looking into this? There is definitely value in more consistent logging approach within the code, but things may have moved around a bit since your initial issue was raised (and we are also at python 3.8+) |
Beta Was this translation helpful? Give feedback.
-
PyEmu
implements a custom logger to log messages from various parts of the package. Python comes with alogging
module that provides the same functionality, and more. Also,PstFrom
is currently hardcoded to log to a file in the current working directory, as well as an optional logging tostdout
. I'm usingpyemu
within asnakemake
workflow, with log files being stored in a dedicated directory, so I would like to be able to specify how and where the messages are logged. The standard library also provides means to configure different log levels for different streams (for example debug and info messages only to file, but warnings and errors also to the screen, or even custom log handlers).Would you guys be open to a pull request that replaces the current logger with the built-in
logging
interface? It would mean that some options need to be removed, such as theecho
argument to various helpers. We would also need to add a small tutorial for people who would like to keep the current functionality of logging to both a file and stdout, but in return the users get more flexibility both in what is logged as well as how it is logged. This removes some (in my humble opinion ;-) ) unneccessarily opnionated implementation from library code, which makes the library more pythonic.Beta Was this translation helpful? Give feedback.
All reactions