2024-02-16 15:07:10 +00:00
|
|
|
import logging
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
def get_logger(name: str) -> logging.Logger:
|
|
|
|
formatter = logging.Formatter(
|
2024-02-16 20:55:09 +00:00
|
|
|
"%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s"
|
2024-02-16 15:07:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# file_handler = logging.FileHandler('log.txt')
|
|
|
|
# file_handler.setFormatter(formatter)
|
|
|
|
# file_handler.setLevel(logging.INFO)
|
|
|
|
|
|
|
|
out_handler = logging.StreamHandler(stream=sys.stdout)
|
|
|
|
out_handler.setFormatter(formatter)
|
|
|
|
out_handler.setLevel(logging.INFO)
|
|
|
|
|
|
|
|
logger = logging.getLogger(name)
|
|
|
|
# logger.addHandler(file_handler)
|
|
|
|
logger.addHandler(out_handler)
|
|
|
|
logger.setLevel(logging.INFO)
|
|
|
|
return logger
|