You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
Python
53 lines
1.2 KiB
Python
#! /usr/bin/python3
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger('FFX')
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
testLogger = logging.getLogger('FFX Test')
|
|
testLogger.setLevel(logging.DEBUG)
|
|
|
|
|
|
# create file handler that logs debug and higher level messages
|
|
ffxFileHandler = logging.FileHandler('ffx.log')
|
|
ffxFileHandler.setLevel(logging.DEBUG)
|
|
|
|
# create file handler that logs debug and higher level messages
|
|
ffxTestReportFileHandler = logging.FileHandler('ffx_test_report.log')
|
|
ffxTestReportFileHandler.setLevel(logging.DEBUG)
|
|
|
|
# create console handler with a higher log level
|
|
ffxConsoleHandler = logging.StreamHandler()
|
|
#ffxConsoleHandler.setLevel(logging.ERROR)
|
|
|
|
# create formatter and add it to the handlers
|
|
formatter = logging.Formatter(
|
|
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
ffxConsoleHandler.setFormatter(formatter)
|
|
ffxFileHandler.setFormatter(formatter)
|
|
|
|
|
|
# add the handlers to logger
|
|
testLogger.addHandler(ffxConsoleHandler)
|
|
|
|
|
|
logger.addHandler(ffxConsoleHandler)
|
|
logger.addHandler(ffxFileHandler)
|
|
|
|
|
|
|
|
logger.debug('debug message')
|
|
logger.info('info message')
|
|
logger.warning('warn message')
|
|
logger.error('error message')
|
|
logger.critical('critical message')
|
|
|
|
|
|
testLogger.info('TEST: info message')
|
|
|
|
|
|
|
|
click / consoleLogger
|
|
|