Kitware / tangelo

A simple, quick, powerful web framework
http:/tangelohub.org/tangelo/
Apache License 2.0
185 stars 35 forks source link

Enable verbosity. #525

Closed manthey closed 9 years ago

manthey commented 9 years ago

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.

waxlamp commented 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?

manthey commented 9 years ago

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.

waxlamp commented 9 years ago

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.

waxlamp commented 9 years ago

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.

waxlamp commented 9 years ago

@manthey please take a look and let me know if there are any glaring problems with my commits. Thanks!

waxlamp commented 9 years ago

I made a few changes. @manthey, please let me know if they LGTY.

manthey commented 9 years ago

Your changes LGTM.