#!/usr/bin/python3.5 # game bot exception logger import logging from logging import FileHandler from logging import Formatter exc_log_file = 'Game_log/gameexc.log' selectors_log_file = 'Game_log/selectors.log' exc_logger = logging.getLogger('game_bot.exceptions') exc_logger.setLevel(logging.DEBUG) exc_logger_fhandler = FileHandler(exc_log_file) exc_logger_fhandler.setLevel(logging.DEBUG) exc_logger_fhandler.setFormatter(Formatter('%(asctime)s [%(levelname)s]: %(message)s %(lineno)d')) exc_logger.addHandler(exc_logger_fhandler) selector_logger = logging.getLogger('game_bot.selectors') selector_logger.setLevel(logging.INFO) selector_logger_fhandler = FileHandler(selectors_log_file) selector_logger_fhandler.setLevel(logging.INFO) selector_logger_fhandler.setFormatter(Formatter('%(asctime)s [%(levelname)s]: %(message)s %(lineno)d')) selector_logger.addHandler(selector_logger_fhandler) if __name__ == '__main__': try: assert 6 == 6 exc_logger.info('True') except AssertionError as exc: exc_logger.exception(exc)