Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions _delphi_utils_python/delphi_utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,12 @@ def get_structured_logger(name=__name__,
is a good choice.
filename: An (optional) file to write log output.
"""
# Configure the underlying logging configuration
handlers = [logging.StreamHandler()]
if filename:
handlers.append(logging.FileHandler(filename))

# Configure the basic underlying logging configuration
logging.basicConfig(
format="%(message)s",
level=logging.INFO,
handlers=handlers
)
handlers=[logging.StreamHandler()]
)

# Configure structlog. This uses many of the standard suggestions from
# the structlog documentation.
Expand Down Expand Up @@ -84,7 +80,12 @@ def get_structured_logger(name=__name__,
cache_logger_on_first_use=True,
)

logger = structlog.get_logger(name)
# Create the underlying python logger and wrap it with structlog
system_logger = logging.getLogger(name)
if filename:
system_logger.addHandler(logging.FileHandler(filename))
system_logger.setLevel(logging.INFO)
logger = structlog.wrap_logger(system_logger)

if log_exceptions:
handle_exceptions(logger)
Expand Down