logging

formatters

%(pathname)s Full pathname of the source file where the logging call was issued(if available).
%(filename)s Filename portion of pathname.
%(module)s Module (name portion of filename).
%(funcName)s Name of function containing the logging call.
%(lineno)d Source line number where the logging call was issued (if available).

handlers

StreamHandler

The StreamHandler class, located in the core logging package, sends logging output to streams such as sys.stdout, sys.stderr or any file-like object (or, more precisely, any object which supports write() and flush() methods).

class logging.StreamHandler(stream=None)
Returns a new instance of the StreamHandler class. If stream is specified, the instance will use it for logging output; otherwise, sys.stderr will be used
def _add_logging_handler_if_needed():
    _one_logger = logging.getLogger('one')
    def has_any_handler(logger):
        while logger:
            if logger.handlers:
                return True
            if logger.propagate:
                logger = logger.parent
        return False
    if not has_any_handler(_one_logger):
        _one_logger.addHandler(logging.StreamHandler())