Skip to content

Latest commit

 

History

History
42 lines (32 loc) · 1.06 KB

File metadata and controls

42 lines (32 loc) · 1.06 KB

Irolog

Irolog is a custom formatter intended to be used with Python's logging module. It helps colorize the logs being outputted to the standard output(STDOUT)/console. As of now, it is just a bare skeleton.(Development in progress)

Usage

import logging
from irolog.formatter import ColoredLogFormatter

def configure_logging():
    fh = logging.StreamHandler()
    f = ColoredLogFormatter('%(asctime)s|%(levelname)s|%(message)s|',
                                  '%d/%m/%Y %H:%M:%S')
    fh.setFormatter(f)
    root = logging.getLogger()
    root.setLevel(logging.DEBUG)
    root.addHandler(fh)


def main():
    configure_logging()
    logging.info('Sample message')
    logging.warning('Sample message')
    logging.debug('Sample message')
    logging.error('Sample message')
    logging.critical('Sample message')
    try:
        x = 1 / 0
    except ZeroDivisionError as e:
        logging.exception('ZeroDivisionError: %s', e)


if __name__ == '__main__':
    main()

Output

Colored Output