geowatch.utils.util_logging module¶
Todo
[ ] This needs to be cleaned up. Python logging is way too global for my
taste. I would prefer something more instance level, but that will require some thought. The netharn.FitHarn has a way of accomplishing this that I reasonably like. That might be worth generalizing and porting here. But for now, this will remain somewhat ad-hoc.
- geowatch.utils.util_logging.setup_logging(verbose=1)[source]¶
Define logging level
- Parameters:
verbose (int) –
- Accepted values:
0: no logging
1: INFO level
2: DEBUG level
- class geowatch.utils.util_logging.PrintLogger(name='<print-logger>', level=None, verbose=1)[source]¶
Bases:
object
Simple print-based logger that duck-types the logging.Logger class and “simply works” without configuration.
Example
>>> from geowatch.utils.util_logging import * # NOQA >>> logger = PrintLogger(level=logging.INFO) >>> logger.info('hello') >>> logger.debug('world') hello >>> logger = PrintLogger(level=logging.DEBUG) >>> logger.info('hello') >>> logger.debug('world') hello world
- exception(msg, *args, exc_info=True, **kwargs)[source]¶
Convenience method for logging an ERROR with exception information.
- findCaller(stack_info=False, stacklevel=1)[source]¶
Find the stack frame of the caller so that we can note the source file name, line number and function name.
- makeRecord(name, level, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None)[source]¶
A factory method which can be overridden in subclasses to create specialized LogRecords.
- handle(record)[source]¶
Call the handlers for the specified record.
This method is used for unpickled records received from a socket, as well as those created locally. Logger-level filtering is applied.
- hasHandlers()[source]¶
See if this logger has any handlers configured.
Loop through all handlers for this logger and its parents in the logger hierarchy. Return True if a handler was found, else False. Stop searching up the hierarchy whenever a logger with the “propagate” attribute set to zero is found - that will be the last logger which is checked for the existence of handlers.