Logger

fullrmc’s logger is a singleton of pysimplelog. You can always access fullrmc’s logger instance and modify its settings. In fullrmc, logger is a global object and therefore can be imported from Globals module as the following.

# import fullrmc modules
from fullrmc.Globals import LOGGER

# you can always print the logger to visualize it's properties
print(LOGGER)
Logger (Version 1.0.0)
log type       |log name       |level     |std flag  |file flag |
---------------|---------------|----------|----------|----------|
move not tried |INFO           |-15.0     |False     |False     |
move rejected  |INFO           |-10.0     |False     |False     |
debug          |DEBUG          |0.0       |False     |False     |
info           |INFO           |10.0      |True      |True      |
move accepted  |INFO           |15.0      |True      |True      |
engine saved   |INFO           |17.0      |True      |True      |
argument fixed |FIXED          |20.0      |True      |True      |
warn           |WARNING        |20.0      |True      |True      |
error          |ERROR          |30.0      |True      |True      |
critical       |CRITICAL       |100.0     |True      |True      |
implement      |IMPLEMENTATION |100.0     |True      |True      |
usage          |USAGE          |1000.0    |True      |True      |

As you can see many logging types exist with different logging levels and flags. Refer to pysimplelog’s documentation if you need to understand more about how to tweak logger’s settings. What can be useful to know, is that logging comes at a cost but in fullrmc’s case it’s very minimal because logging is invoked smartly and only when it makes sense. As a rule of thumb, the bigger the modeled system is the less one needs to care about how long it takes to log anything because engine’s step time increases linearly with the number of atoms but logging doesn’t. Depending on the machine, logging a message simultaneously to the standard output and to a file can take anything between few micro-seconds to milliseconds. At engine’s runtime, using fullrmc’s default settings, only accepted moves are logged. One can do the math now and see how much logging can add to engine’s runtime step.

In order to shut down all logging except for errors and critical errors one can do the following:

# standard library imports
import sys

# import fullrmc modules
from fullrmc.Globals import LOGGER, maxint

# set minimum allowed level to system's maximum integer for both
# standard output (terminal) and logger's file
LOGGER.set_minimum_level(maxint, stdoutFlag=True, fileFlag=True)

# you can always print the logger to visualize it's properties
print(LOGGER)
Logger (Version 1.0.0)
log type       |log name       |level     |std flag  |file flag |
---------------|---------------|----------|----------|----------|
move not tried |INFO           |-15.0     |False     |False     |
move rejected  |INFO           |-10.0     |False     |False     |
debug          |DEBUG          |0.0       |False     |False     |
info           |INFO           |10.0      |False     |False     |
move accepted  |INFO           |15.0      |False     |False     |
engine saved   |INFO           |17.0      |False     |False     |
argument fixed |FIXED          |20.0      |False     |False     |
warn           |WARNING        |20.0      |False     |False     |
error          |ERROR          |30.0      |True      |True      |
critical       |CRITICAL       |100.0     |True      |True      |
implement      |IMPLEMENTATION |100.0     |False     |False     |
usage          |USAGE          |1000.0    |False     |False     |

In the above example error and critical log types are forced to True at all time regardless of logging level. If one wants to shut down forced types as well the following should be done.

# import fullrmc modules
from fullrmc.Globals import LOGGER

# print forced levels
print('before stdout:',LOGGER.forcedStdoutLevels)
print('before file:',  LOGGER.forcedFileLevels)

# force a type to logging or not regardless it's logging level
LOGGER.force_log_type_flags(logType='error',    stdoutFlag=False, fileFlag=False)
LOGGER.force_log_type_flags(logType='critical', stdoutFlag=False, fileFlag=False)

# print forced levels
print('after stdout:',LOGGER.forcedStdoutLevels)
print('after file:',  LOGGER.forcedFileLevels)

# you can always print the logger to visualize it's properties
print(LOGGER)
before stdout: {'critical': True, 'error': True}
before file: {'critical': True, 'error': True}
after stdout: {'critical': False, 'error': False}
after file: {'critical': False, 'error': False}

Logger (Version 1.0.0)
log type       |log name       |level     |std flag  |file flag |
---------------|---------------|----------|----------|----------|
move not tried |INFO           |-15.0     |False     |False     |
move rejected  |INFO           |-10.0     |False     |False     |
debug          |DEBUG          |0.0       |False     |False     |
info           |INFO           |10.0      |False     |False     |
move accepted  |INFO           |15.0      |False     |False     |
engine saved   |INFO           |17.0      |False     |False     |
argument fixed |FIXED          |20.0      |False     |False     |
warn           |WARNING        |20.0      |False     |False     |
error          |ERROR          |30.0      |False     |False     |
critical       |CRITICAL       |100.0     |False     |False     |
implement      |IMPLEMENTATION |100.0     |False     |False     |
usage          |USAGE          |1000.0    |False     |False     |