Logging_module

PHOTO EMBED

Thu Mar 04 2021 08:37:23 GMT+0000 (Coordinated Universal Time)

Saved by @Bartok #python

import logging

logging.basicConfig(
    format='%(asctime)s %(levelname) -8s [%(filename)s:%(lineno)d]  %(message)s',
    level=logging.DEBUG,
    datefmt= '%Y-%m-%d %H:%M:%S',
    filename= 'log.txt'
)

#s - turn it to a string

logger = logging.getLogger('test_log')

logger.info('This will not show up')
logger.warning('This will')
logger.error('this is error')
logger.critical('Critical error')


"""
DEBUG
INFO

#those show up by default
WARNING
ERROR
CRITICAL

"""
content_copyCOPY