Closed manthey closed 9 years ago
@manthey do these logging levels form an inclusiveness hierarchy? How does it work? For instance, I generally want to see the "Tangelo is running" message on the log when I launch Tangelo, to ensure at a glance that I didn't attempt to use the wrong port, etc. In the default case, will I see those "success" messages?
Yes.
Tangelo uses cherrypy, which uses python logs and log levels. Cherrypy has two sets of logs, access_log which logs URLs that get served, and error_log which logs anything else. tangelo.log logs to the cherrypy error_log.
Since this uses the Python logging module under the hood, the log levels are specified here: https://docs.python.org/2/library/logging.html#logging-levels . You can set the log level of a log handler, and then any message with a log level equal to or greater than the handler's log level will actually be logged.
Therefore, if the log is logged as logging.WARNING
(== 30), it will show up if the log level (our verbosity) is set to any value <= 30, and not be printed if the value > 30.
I picked some log levels for the different tangelo.log_* methods that I thought made sense. Simply, if you run tangelo without any specification, you'll get the same messages now as you did before. tangelo -q
will pretty much only print 'TANGELO Server is running' and 'TANGELO Be seeing you.', plus whatever the plugins cause. tangelo -qq
will probably be completely silent unless there are errors. tangelo -v
currently doesn't print more than tangelo
, but we can add tangelo.log_debug()
calls which wouldn't show without it.
Very cool. Let me poke around a bit with this before I sign off on it. Thanks @manthey!
On Wed, Sep 30, 2015 at 2:46 PM David Manthey notifications@github.com wrote:
Yes.
Tangelo uses cherrypy, which uses python logs and log levels. Cherrypy has two sets of logs, access_log which logs URLs that get served, and error_log which logs anything else. tangelo.log logs to the cherrypy error_log.
Since this uses the Python logging module under the hood, the log levels are specified here: https://docs.python.org/2/library/logging.html#logging-levels . You can set the log level of a log handler, and then any message with a log level equal to or greater than the handler's log level will actually be logged.
Therefore, if the log is logged as logging.WARNING (== 30), it will show up if the log level (our verbosity) is set to any value <= 30, and not be printed if the value > 30.
I picked some log levels for the different tangelo.log_* methods that I thought made sense. Simply, if you run tangelo without any specification, you'll get the same messages now as you did before. tangelo -q will pretty much only print 'TANGELO Server is running' and 'TANGELO Be seeing you.', plus whatever the plugins cause. tangelo -qq will probably be completely silent unless there are errors. tangelo -v currently doesn't print more than tangelo, but we can add tangelo.log_debug() calls which wouldn't show without it.
— Reply to this email directly or view it on GitHub https://github.com/Kitware/tangelo/pull/525#issuecomment-144504390.
I like this a lot. I'm going to reconfigure the existing log functions a bit and fill in a few for the other named log levels. I like defaulting the level to INFO
but I'm going to basically get rid of the log_success()
function, which I think doesn't make too much sense.
@manthey please take a look and let me know if there are any glaring problems with my commits. Thanks!
I made a few changes. @manthey, please let me know if they LGTY.
log_success()
since "success" is not a standard log level - we were only using it for messages that are just as well handled by log_info()
anywaylog_critical()
function to match up with that standard log levellog_debug()
we don't need this to be bold anymore-q
.log()
calls - all such calls were turned into log_info()
callsYour changes LGTM.
Hithertofore, the verbosity option did nothing. We now default to a log level of INFO, and adding --verbose or -v increases the log level. Adding --quiet or -q decreases the log level. Added a tangelo.log_debug method, and tangelo.log can have a lvl specified.