Skip to content

Commit

Permalink
Update logging.py
Browse files Browse the repository at this point in the history
Only add "encoding" parameter if Python 3.9 or later
  • Loading branch information
ianhelle committed Mar 29, 2023
1 parent 559f910 commit cfef44c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions msticpy/init/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""Logging global config."""
import logging
import os
import sys
from typing import NamedTuple, Optional, Union

from .._version import VERSION
Expand Down Expand Up @@ -55,11 +56,14 @@ def set_logging_level(log_level: Union[int, str]):
def setup_logging():
"""Initiate logging."""
logging_config = _get_logging_config()
# encoding param only supported in 3.9+
params_39 = {"encoding": "utf-8"} if sys.version_info >= (3, 9) else {}
logging.basicConfig(
filename=logging_config.log_file,
encoding="utf-8",
level=logging_config.log_level,
format="%(asctime)s: %(levelname)s - %(message)s (%(module)s#%(lineno)d)",
**params_39,
)


Expand Down

0 comments on commit cfef44c

Please sign in to comment.