Skip to content

Commit

Permalink
Always use UTF-8 for log file encoding (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiasli committed May 8, 2021
1 parent 50d30cf commit f377ca8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.8.2
+++++

* Always use UTF-8 for log file encoding (#247)

0.8.1
+++++

Expand Down
5 changes: 4 additions & 1 deletion knack/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# without --debug flag.
cli_logger_names = [CLI_LOGGER_NAME]

LOG_FILE_ENCODING = 'utf-8'


class CliLogLevel(IntEnum):
CRITICAL = 0
Expand Down Expand Up @@ -163,7 +165,8 @@ def _init_logfile_handlers(self, root_logger, cli_loggers):
ensure_dir(self.log_dir)
log_file_path = os.path.join(self.log_dir, self.logfile_name)
from logging.handlers import RotatingFileHandler
logfile_handler = RotatingFileHandler(log_file_path, maxBytes=10 * 1024 * 1024, backupCount=5)
logfile_handler = RotatingFileHandler(log_file_path, maxBytes=10 * 1024 * 1024, backupCount=5,
encoding=LOG_FILE_ENCODING)
lfmt = logging.Formatter('%(process)d : %(asctime)s : %(levelname)s : %(name)s : %(message)s')
logfile_handler.setFormatter(lfmt)
logfile_handler.setLevel(logging.DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = '0.8.1'
VERSION = '0.8.2'

DEPENDENCIES = [
'argcomplete',
Expand Down

0 comments on commit f377ca8

Please sign in to comment.