log/template
This commit is contained in:
parent
78dd431ca5
commit
bf1b3402ae
1 changed files with 8 additions and 3 deletions
|
@ -7,9 +7,14 @@ import sys
|
|||
def get_file_logger(name: str) -> logging.Logger:
|
||||
"""Return a file logger."""
|
||||
# formatter
|
||||
formatter = logging.Formatter(
|
||||
"%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s",
|
||||
)
|
||||
items = [
|
||||
"%(name)s: %(asctime)s",
|
||||
"%(levelname)s",
|
||||
"%(filename)s:%(lineno)s",
|
||||
"%(process)d >>> %(message)s",
|
||||
]
|
||||
template = " | ".join(items)
|
||||
formatter = logging.Formatter(template)
|
||||
# handler
|
||||
out_handler = logging.StreamHandler(stream=sys.stdout)
|
||||
out_handler.setFormatter(formatter)
|
||||
|
|
Loading…
Reference in a new issue