Logs

Set up some system-wide loggers

The logs Module

Set up some system-wide loggers

class openquake.engine.logs.LogDatabaseHandler(job)[source]

Bases: logging.Handler

Log stream handler

emit(record)[source]
class openquake.engine.logs.LogFileHandler(job, log_file)[source]

Bases: logging.FileHandler

Log file handler

emit(record)[source]
class openquake.engine.logs.LogStreamHandler(job)[source]

Bases: logging.StreamHandler

Log stream handler

emit(record)[source]
openquake.engine.logs.handle(*args, **kwds)[source]

Context manager adding and removing log handlers.

Parameters:
  • job – a openquake.engine.db.models.OqJob instance
  • log_level – one of debug, info, warn, progress, error, critical
  • log_file – log file path (if None, logs on stdout only)
openquake.engine.logs.set_level(level)[source]

Initialize logs to write records with level level or above.

openquake.engine.logs.touch_log_file(log_file)[source]

If a log file destination is specified, attempt to open the file in ‘append’ mode (‘a’). If the specified file is not writable, an IOError will be raised.

class openquake.engine.logs.tracing(msg)[source]

Bases: object

Simple context manager util to handle tracing. E.g.

with log(“exports”):
do_export()