forked from keysmashes/edmcoverlay2
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path_logger.py
More file actions
30 lines (25 loc) · 1.16 KB
/
Copy path_logger.py
File metadata and controls
30 lines (25 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# See: https://github.com/EDCD/EDMarketConnector/blob/main/PLUGINS.md
# Use: from _logger import logger
import logging
import os
from config import appname
DEFAULT_LOG_LEVEL = logging.INFO
# This could also be returned from plugin_start3()
__plugin_name = os.path.basename(os.path.dirname(__file__))
# A Logger is used per 'found' plugin to make it easy to include the plugin's
# folder name in the logging output format.
# NB: plugin_name here *must* be the plugin's folder name as per the preceding
# code, else the logger won't be properly set up.
logger = logging.getLogger(f"{appname}.{__plugin_name}")
# If the Logger has handlers then it was already set up by the core code, else
# it needs setting up here.
if not logger.hasHandlers():
logger.setLevel(DEFAULT_LOG_LEVEL)
logger_channel = logging.StreamHandler()
logger_formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(module)s:%(lineno)d:%(funcName)s: %(message)s"
)
logger_formatter.default_time_format = "%Y-%m-%d %H:%M:%S"
logger_formatter.default_msec_format = "%s.%03d"
logger_channel.setFormatter(logger_formatter)
logger.addHandler(logger_channel)