Closed yarikoptic closed 4 years ago
Related #17 what do you think about logging on the level of different executors, also to file?
"to file" -- makes total sense by default for the dashboard! (eventually might even want to handle HUP signal to close/open that logging backend so logrotate could do its job ;))
But for cmdline tools, even though we support such functionality everywhere, I barely ever use it. I guess because I do want to see logging lines interleaved with actual output.
FWIW, I do "love logging"... or to say I rely on logging a lot for a variety of use cases, largely for troubleshooting, debugging, and even optimization. That is why in DataLad we actually have quite a number of features bolted on to the logging (here is the implementation which you might be interested to poke at or just adopt entirely). All of those are controlled via our config (or where forgotten - purely through env variables), see the _LOG
ones in https://github.com/datalad/datalad/blob/master/CONTRIBUTING.md#useful-environment-variables
I do often use adding timestamps, including the traceback and PID into the log lines. Also there is a little dtime (difference in time) helper which I can feed with a log output
without resorting to the full scale profiling etc.
(BTW - that is how you could quickly figure out where we log any ERROR line we might want to helpme with ;))
BTW, at least for .debug
(and "lower") levels of logging I would recommend to rely on ability to pass string interpolation arguments directly into the call, e.g. instead of
app.logger.debug("Received deletion request for %s" % json.get("taskid"))
use
app.logger.debug("Received deletion request for %s", json.get("taskid"))
then interprolation would be performed only if that line is to be logged. This way you could be more generous with .debug
log lines while minimizing their negative impact
PS now thinking about it -- I could have had dtime
as just yet another _LOG
option, d'oh! ;)
There is an environment variable you can set for qme - MESSAGELEVEL
akin to helpme (and I'll update to be QME_MESSAGELEVEL)
From #34 we also want:
Consider using common prefix for all env var related to logging, eg shorter QMELOG. Then you could uniformly add more settings as needed. I will also appreciate it personally since that is the convention I used in a good number of projects
@yarikoptic take a look! #35 I added a snippet of documentation for how it works so be sure to look at that file. I was going for a simple, clean implementation that would make it easy to customize via environment or client.
probably it is possible to configure logging via ~/.qme/config.ini file, but I find it super useful to be able to configure logging for a specific invocation. For that e.g. in majority of the tools I touch we have
-l|--loglevel
option at the top level of the interface which is typically also configurable via environment variable. E.g.:Command line option overrides env variable, and that one overrides possible config file setting. This way I could easily start/restart dashboard with different logging level while running
qme run
with default or another.ATM
qme show
floods terminal with some logs, so those should be demoted to DEBUG level but I could make them visible by quickly restarting with-l debug
if interested to see them.