File size: 603 Bytes
dbac7c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import logging
import os
from logging.handlers import RotatingFileHandler

log_file_name = "workdir/UniPortrait.log"
os.makedirs(os.path.dirname(log_file_name), exist_ok=True)

format = '[%(levelname)s] %(asctime)s "%(filename)s", line %(lineno)d, %(message)s'
logging.basicConfig(
    format=format,
    datefmt="%Y-%m-%d %H:%M:%S",
    level=logging.INFO)
logger = logging.getLogger(name="UniPortrait-Studio")

fh = RotatingFileHandler(log_file_name, maxBytes=20000000, backupCount=3)
formatter = logging.Formatter(format, datefmt="%Y-%m-%d %H:%M:%S")
fh.setFormatter(formatter)
logger.addHandler(fh)