Source code for chains.utils.log_utils

"""Log utilities that might be useful"""
from __future__ import print_function

import os
import logging

[docs]def get_logger(): """Setup logging output defaults""" # Grab the logger if not hasattr(get_logger, 'logger'): # Setup the default logging config get_logger.logger = logging.getLogger('chains') format_str = '%(asctime)s [%(levelname)s] - %(module)s: %(message)s' logging.basicConfig(datefmt='%Y-%m-%d %H:%M:%S', level=logging.INFO, format=format_str) # Return the logger return get_logger.logger
[docs]def panic(mesg): """Throw a critical message and raise a runtime exceptions""" get_logger().critical(mesg) raise RuntimeError(mesg)
[docs]def test_utils(): """Test the utility methods""" logger = get_logger() logger.debug('Test debug log message')'Test information log message') logger.warn('Test warning log message') logger.error('Test error log message') logger.critical('Test critical log message') print('Success!')
if __name__ == '__main__': test_utils()