Skip to content

Commit

Permalink
Extend logutils to accept additional handlers.
Browse files Browse the repository at this point in the history
(cherry picked from commit 483c68b)
  • Loading branch information
davner authored and chris-simpson committed Jan 7, 2025
1 parent 1878b48 commit fa48f0f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions gempy/utils/logutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def get_logger(name=None):
customize_log(log)
return log

def config(mode='standard', file_name=None, file_lvl=15, stomp=False):
def config(mode='standard', file_name=None, file_lvl=15, stomp=False,
additional_handlers=None):
"""
Controls Dragons logging configuration.
Expand All @@ -136,9 +137,13 @@ def config(mode='standard', file_name=None, file_lvl=15, stomp=False):
file_name : <atr>
filename of the logger
stomp: <bool>
stomp : <bool>
Controls append to logfiles found with same name
additional_handlers : `logging.Handler` or <list>
An initialized handler or a list of initialized handlers to be added to the
root logger.
Returns
-------
<void>
Expand Down Expand Up @@ -203,6 +208,14 @@ def config(mode='standard', file_name=None, file_lvl=15, stomp=False):
log_handler.setLevel(file_lvl)
rootlog.addHandler(log_handler)

# Attach additional handlers if provided.
if additional_handlers is not None:
if isinstance(additional_handlers, list):
for handler in additional_handlers:
rootlog.addHandler(handler)
else:
rootlog.addHandler(additional_handlers)

return

def update_indent(li=0, mode=''):
Expand Down

0 comments on commit fa48f0f

Please sign in to comment.