Skip to content

Commit

Permalink
Check for DarkNews.ModelContainer.configure_logger in case it is remo…
Browse files Browse the repository at this point in the history
…ved in the future.
  • Loading branch information
austinschneider committed Aug 29, 2024
1 parent 5a4c772 commit c09e6d5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions resources/Processes/DarkNewsTables/logger.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Monkey patch DarkNews logger to hide printouts
import functools

from DarkNews.ModelContainer import ModelContainer
ModelContainer_configure_logger = ModelContainer.configure_logger
dn_has_modelcontainer_logger = False
try:
from DarkNews.ModelContainer import ModelContainer
ModelContainer_configure_logger = ModelContainer.configure_logger
dn_has_modelcontainer_logger = True
except:
pass

@functools.wraps(ModelContainer.configure_logger)
def suppress_info(self, logger, loglevel="INFO", prettyprinter=None, logfile=None, verbose=False):
return ModelContainer_configure_logger(self, logger, loglevel="WARNING", prettyprinter=prettyprinter, logfile=logfile, verbose=verbose)
if dn_has_modelcontainer_logger:
@functools.wraps(ModelContainer.configure_logger)
def suppress_info(self, logger, loglevel="INFO", prettyprinter=None, logfile=None, verbose=False):
return ModelContainer_configure_logger(self, logger, loglevel="WARNING", prettyprinter=prettyprinter, logfile=logfile, verbose=verbose)

ModelContainer.configure_logger = suppress_info
ModelContainer.configure_logger = suppress_info

0 comments on commit c09e6d5

Please sign in to comment.