forked from sotolko/csgo-market-sniper
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlogger.py
28 lines (22 loc) · 812 Bytes
/
logger.py
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
import logging
def prepare_buy_log() -> logging.Logger:
"""
Sets up a logger to record purchase details.
Returns:
logger (logging.Logger): A configured logger for recording purchase details.
"""
# Initialize a logger
logger = logging.getLogger('BUY')
logger.setLevel(logging.INFO)
logger.propagate = False
# If no handlers are configured, set up a file handler
if not logger.handlers:
file_handler = logging.FileHandler("buy.log", mode='a')
file_handler.setLevel(logging.INFO)
formatter = logging.Formatter(
'[%(asctime)s] %(name)s > %(message)s', datefmt='%m/%d/%Y %I:%M:%S%p'
)
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
# Return the configured logger
return logger