You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
658 B
20 lines
658 B
5 years ago
|
import logging
|
||
|
|
||
|
|
||
|
def init_logger():
|
||
|
logger = logging.getLogger() # get the root logger
|
||
|
logger.setLevel(logging.DEBUG)
|
||
|
|
||
|
handler = logging.StreamHandler()
|
||
|
handler.setLevel(logging.DEBUG)
|
||
|
formatter = logging.Formatter("[%(levelname)s] %(message)s")
|
||
|
handler.setFormatter(formatter)
|
||
|
logger.addHandler(handler)
|
||
|
|
||
|
trace_handler = logging.FileHandler("trace.log", "w")
|
||
|
trace_handler.setLevel(logging.INFO)
|
||
|
# trace_formatter = logging.Formatter("%(asctime)s[%(levelname)s],%(message)s")
|
||
|
trace_formatter = logging.Formatter("%(message)s")
|
||
|
trace_handler.setFormatter(trace_formatter)
|
||
|
logger.addHandler(trace_handler)
|