Skip to content

Commit b8a5c85

Browse files
committed
Update logger to handle unicode
1 parent 4e32442 commit b8a5c85

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

config.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,35 @@ def is_installed():
9292

9393
LOG_FILENAME = utils.get_data_file_path(ERROR_LOG_FILE)
9494

95+
def getLogHandler():
96+
return lh.RotatingFileHandler(
97+
LOG_FILENAME,
98+
maxBytes=100000,
99+
backupCount=2,
100+
encoding='utf-8'
101+
)
102+
103+
95104
if DEBUG:
96105
logging.basicConfig(
97-
filename=LOG_FILENAME,
98106
format=("%(levelname) -10s %(asctime)s %(module)s.py: "
99107
"%(lineno)s %(funcName)s - %(message)s"),
100-
level=logging.DEBUG
108+
level=logging.DEBUG,
109+
handlers=[getLogHandler()]
101110
)
102111
else:
103112
logging.basicConfig(
104-
filename=LOG_FILENAME,
105113
format=("%(levelname) -10s %(asctime)s %(module)s.py: "
106114
"%(lineno)s %(funcName)s - %(message)s"),
107-
level=logging.INFO
115+
level=logging.INFO,
116+
handlers=[getLogHandler()]
108117
)
109118

110119

111120

112121
def getLogger(name):
113122
logger = logging.getLogger(name)
114-
handler = lh.RotatingFileHandler(LOG_FILENAME,
115-
maxBytes=100000,
116-
backupCount=2)
117-
logger.addHandler(handler)
123+
logger.addHandler(getLogHandler())
118124
return logger
119125

120126

0 commit comments

Comments
 (0)