-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for DarkNews.ModelContainer.configure_logger in case it is remo…
…ved in the future.
- Loading branch information
1 parent
5a4c772
commit c09e6d5
Showing
1 changed file
with
12 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|