MCPcopy Index your code
hub / github.com/dothinking/PyAddin / __config_logger

Function __config_logger

pyaddin/resources/scripts/utils/context.py:66–96  ·  view source on GitHub ↗

Log settings based on configuration file under working path.

(working_path:str)

Source from the content-addressed store, hash-verified

64
65
66def __config_logger(working_path:str) -> logging.Logger:
67 '''Log settings based on configuration file under working path.'''
68 # log files
69 output_file, error_file, debug_file = __check_log_files(working_path=working_path)
70
71 # full level log
72 log = logging.FileHandler(filename=debug_file, mode='w', encoding='utf-8')
73 log.setLevel(level=logging.DEBUG)
74 fmt = logging.Formatter(fmt="%(asctime)s - %(name)s - %(levelname)s -%(module)s: %(message)s", datefmt='%Y-%m-%d %H:%M:%S')
75 log.setFormatter(fmt)
76
77 # normal output
78 output = logging.FileHandler(filename=output_file, mode='w', encoding='utf-8')
79 output.setLevel(level=logging.INFO)
80
81 # error
82 error = logging.FileHandler(filename=error_file, mode='w', encoding='utf-8')
83 error.setLevel(level=logging.ERROR)
84
85 # console
86 console = logging.StreamHandler()
87 console.setLevel(logging.DEBUG)
88
89 # logger
90 logger = logging.Logger(name='addin_logger', level=logging.DEBUG)
91 logger.addHandler(log)
92 logger.addHandler(output)
93 logger.addHandler(error)
94 logger.addHandler(console)
95
96 return logger
97
98
99def __check_log_files(working_path:str):

Callers 1

set_loggerFunction · 0.85

Calls 1

__check_log_filesFunction · 0.85

Tested by

no test coverage detected