Skip to content

Commit

Permalink
Merge pull request #24 from int-brain-lab/fix/unicode-log
Browse files Browse the repository at this point in the history
Fix/unicode log
  • Loading branch information
bimac authored Feb 1, 2024
2 parents ea46854 + 8332461 commit b448bf5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog
## [Latest](https://github.com/int-brain-lab/iblutil/commits/main) [1.7.3]
## [Latest](https://github.com/int-brain-lab/iblutil/commits/main) [1.7.4]

### Modified

- setup_logger: use unicode for LOG_FORMAT_STR

## [1.7.3]

- setup_logger: simpler layout
- setup_logger: check class of log.handler instance before accessing class-specific field

Expand Down
2 changes: 1 addition & 1 deletion iblutil/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.7.3'
__version__ = '1.7.4'
4 changes: 2 additions & 2 deletions iblutil/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import numpy as np

LOG_FORMAT_STR = '%(asctime)s %(levelname)-8s %(filename)s:%(lineno)-4d %(message)s'
LOG_FORMAT_STR = u'%(asctime)s %(levelname)-8s %(filename)s:%(lineno)-4d %(message)s'
LOG_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
LOG_COLORS = {
'DEBUG': 'green',
Expand Down Expand Up @@ -208,7 +208,7 @@ def log_to_file(log='ibl', filename=None):
elif not Path(filename).is_absolute():
filename = Path.home().joinpath('.ibl_logs', filename)
filename.parent.mkdir(exist_ok=True)
file_handler = logging.FileHandler(filename)
file_handler = logging.FileHandler(filename, encoding='utf-8')
file_format = logging.Formatter(LOG_FORMAT_STR, LOG_DATE_FORMAT)
file_handler.setFormatter(file_format)
file_handler.name = f'{log.name}_file'
Expand Down

0 comments on commit b448bf5

Please sign in to comment.