Skip to content

Commit b593c95

Browse files
author
Oliver Scott
committed
logging stuff.
1 parent 3127a20 commit b593c95

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

scaffoldgraph/utils/logging.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import functools
8+
import warnings
89

910
from rdkit import __version__ as rdversion
1011
from rdkit import RDLogger, rdBase
@@ -17,10 +18,22 @@
1718
'rdApp.error': True
1819
}
1920

21+
QUIET_RDLOGGER_STATUS = {
22+
'rdApp.debug': False,
23+
'rdApp.info': False,
24+
'rdApp.warning': False,
25+
'rdApp.error': True
26+
}
27+
28+
UNKNOWN_RDLOGGER_STATUS = DEFAULT_RDLOGGER_STATUS
29+
2030

2131
def get_rdlogger_status():
2232
"""dict : Return the status of the rdlogger."""
2333
status_dict = {}
34+
if rdversion < '2020.09.01':
35+
warnings.warn('Failed to get status of rdlogger')
36+
return UNKNOWN_RDLOGGER_STATUS
2437
for status in rdBase.LogStatus().split('\n'):
2538
level, state = status.split(':')
2639
status_dict[level] = True if state == 'enabled' else False
@@ -36,6 +49,16 @@ def set_rdlogger_status(status_dict):
3649
rdBase.DisableLog(level)
3750

3851

52+
def set_rdlogger_quiet():
53+
"""Set the rdlogger to quiet status."""
54+
set_rdlogger_status(QUIET_RDLOGGER_STATUS)
55+
56+
57+
def reset_rdlogger():
58+
"""Reset the rdlogger status to default."""
59+
set_rdlogger_status(DEFAULT_RDLOGGER_STATUS)
60+
61+
3962
def suppress_rdlogger(
4063
suppress_info=True,
4164
suppress_warning=True,

0 commit comments

Comments
 (0)