Skip to main content

Custom logger class using the builtin logging module

Project description

SimpleLogger

Custom logger class using the builtin logging module

  • Simplifies logging to a file
  • Adds color formatting
  • Adds ability to set verbosity through environment variable 'BBLOGGER_VERBOSITY'

Logger class

class SimpleLogger( logging.getLoggerClass() ):

        """
        All options and keyword arguments are optional

        Arguments:
            'name':  str - name given to logger
            'level': int [1-5] - terminal output logging level - default is 3

        Keyword Arguments:
            'date_fmt':        str ['%H:%M:%S'] - date format string
            'html_theme':      str ['plain'] - html theme to use when writing html or pdf
                                - see SimpleLogger.view_html_themes() to print examples
            'terminal_output': bool [True] - whether or not to output logs to terminal
            'logfile':         str - plaintext log file to write in realtime
            'overwrite':       bool [False] - overwrite logfile at initial start of program if existing
            'logfile_level':   int [1-4] - limit logs at or above level given - default is 1
            'logfile_title':   str - prepend text to logfile (shows date and time only by default)
                                - also applies to html/pdf if used
            'to_html':         str [path] - write logs to an html file at exit of program
            'to_pdf':          bool - use with 'to_html' to instead save a pdf
                                - REQUIREMENT: chrome or chromium and bash in system path
        """


from simplelogger import SimpleLogger
log = SimpleLogger( __name__, 2, logfile = "/home/user/log/my-logfile" )

#
# Setting level does not effect log file
# Log file recieves all logs by default
#

Changelog

  • v0.1.0
    • initial release

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

bb_simplelogger-0.1.0.tar.gz (1.1 MB view hashes)

Uploaded Source

Built Distribution

bb_simplelogger-0.1.0-py3-none-any.whl (1.1 MB 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