Skip to main content

The package wraps the built-in logger. There are options to track the code location from where the log message was created.

Project description

LoggerWrapper Package

This package provides a wrapper for the built-in logging.Logger class:

LoggerWrapper:

The LoggerWrapper class wraps the logging.Logger to pre-configure some of the common tasks like formating.

The LoggerWrapper class has the following methods::

get_output_path(handler_type: logging.Handler=None): Tries to retrieve a list of output targets of the handler that matches the type passed in. If handler_type is None, all the output targets for all the registered handlers are returned. NOTE: Not fully tested

remove_handler(handler_type: logging.Handler=None): Removes the handlers that matches the type passed in. If the handler_type is None or the handler_type is not registered,none of the handlers will be removed. If an abstract handler is given, all handler that have inherited will be removed.

version(): The package version.

Example Usage::

import logging
from logging import handlers as hdls

if __name__ == "__main__":
    name = None
    handlers = [logging.StreamHandler(), hdls.SysLogHandler(address='/dev/log')]
    log = LoggerWrapper(name=name,
                        level=logging.DEBUG,
                        date_filename=True,
                        meta=True,
                        handlers=handlers)

    print("version: " + log.version)

    for count in range(10):
        if count == 5:
            log.remove_handler(logging.StreamHandler)
        log.info("test of " + str(count))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logger_wrapper-0.0.1.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

logger_wrapper-0.0.1-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page