pyworkflow.utils.log module

Module to handle default logging configuration and custom one. Default logging configuration is defined here but optionally, it can be configured with an external json file containing a standard python logging configuration content as documented here: https://docs.python.org/3/howto/logging-cookbook.html#an-example-dictionary-based-configuration To specify a custom logging config file use SCIPION_LOG_CONFIG variable to a json logging configuration file If you just want to change the logger devel use SCIPION_LOG_LEVEL variable (defaults to INFO) See https://docs.python.org/3/howto/logging.html#logging-levels for available levels. Use the literal! not de value.

class pyworkflow.utils.log.LevelFilter(level)[source]

Bases: object

Logging handler filter to filter some levels. e.g.: ERROR

Parameters

level – Level integer value,from which include messages. Value is compared to record.levelno.

filter(record)[source]
class pyworkflow.utils.log.LoggingConfigurator[source]

Bases: object

Class to configure logging scenarios:

1.- GUI logging

2.- Protocol run logging

3.- Other loggings: tests, sync data

customLoggingActive = False
classmethod loadCustomLoggingConfig()[source]

Loads the custom logging configuration file

classmethod setUpGUILogging(logFile=None)[source]

Sets up the logging library for the GUI processes: By default all goes to SCIPION_LOG file and console.

classmethod setUpProtocolRunLogging(stdoutLogFile, stderrLogFile)[source]

Sets up the logging library for the protocols run processes, loads the custom configuration plus 2 FileHandlers for stdout and stderr

classmethod setUpProtocolSchedulingLog(scheduleLogFile)[source]

Sets up the logging for the scheduling process

static setupDefaultLogging(logFile=None, console=True)[source]

Configures logging in a default way that is to file (rotating) and console

Parameters
  • logFile – Optional, path to the log file. Defaults to SCIPION_LOG variable value. If folder does not exists it will be created.

  • console – Optional, defaults to True, so log messages are sent to the terminal as well

classmethod setupLogging(logFile=None, console=True)[source]
class pyworkflow.utils.log.STATUS[source]

Bases: object

EVENT = 'EVENT'
INTERVAL = 'INTERVAL'
START = 'START'
STOP = 'STOP'
pyworkflow.utils.log.getExtraLogInfo(measurement, status, project_name=None, prot_id=None, prot_name=None, step_id=None, duration=None, dbfilename=None)[source]
pyworkflow.utils.log.getFinalProjId(projId)[source]
pyworkflow.utils.log.getFinalProtId(protId)[source]
pyworkflow.utils.log.restoreStdoutAndErr()[source]
pyworkflow.utils.log.setDefaultLoggingContext(protId, projId)[source]