log.get_logger
This commit is contained in:
parent
16d3f72a6d
commit
80a1b90759
1 changed files with 22 additions and 0 deletions
22
log/__init__.py
Normal file
22
log/__init__.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def get_logger(name: str) -> logging.Logger:
|
||||||
|
formatter = logging.Formatter(
|
||||||
|
"%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 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
|
Loading…
Reference in a new issue