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 details)

Uploaded Source

Built Distribution

bb_simplelogger-0.1.0-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file bb_simplelogger-0.1.0.tar.gz.

File metadata

  • Download URL: bb_simplelogger-0.1.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.6.47-1-lts

File hashes

Hashes for bb_simplelogger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 83108aff341246efab5bfeae4e5932519a8c350e9b00c14f34ab80e3ce94f15a
MD5 23425240c744163805defa81bc904a2c
BLAKE2b-256 0dbbdb4c7fccfa049c36db1c8829a6618a6f5f9a67bc59528fac6f238b8c7e59

See more details on using hashes here.

File details

Details for the file bb_simplelogger-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bb_simplelogger-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.6.47-1-lts

File hashes

Hashes for bb_simplelogger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87887fbd59e01f1b3833f90f56a4b149d3e0045224056c5e4a34348b9c5cb787
MD5 93c814d108ccca90a6071d954a1ee724
BLAKE2b-256 b18831d98a253aa5de20a403e5a6855e896ec1d6824dc178554d23912d414360

See more details on using hashes here.

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