armi.runLog module

This module handles logging of console output (e.g. warnings, information, errors) during an armi run.

The default way of using the ARMI runLog is:

import armi.runLog as runLog
runLog.setVerbosity('debug')
runLog.info('information here')
runLog.error('extra error info here')
raise SomeException  # runLog.error() implies that the code will crash!

Note

We plan to reimplement this with the standard Python logging module. It was customized to add a few features in a HPC/MPI environment but we now think we can use the standard system.

armi.runLog.getLogVerbosityLevels()[source]

Return a list of the available log levels (e.g., debug, extra, etc.).

armi.runLog.getLogVerbosityRank(level)[source]

Return integer verbosity rank given the string verbosity name.

class armi.runLog.Log(verbosity=50)[source]

Bases: object

Abstract class that ARMI code calls to be rendered to some kind of log.

Build a log object

Parameters

verbosity (int) – if a msg verbosity is > this, it will be emitted. The default of 50 means only error messages will be emitted. This usually gets adjusted by user settings quickly after instantiation.

flush()[source]
standardLogMsg(msgType, msg, single=False, label=None)[source]

Add formatting to a message and handle its singleness, if applicable.

This is a wrapper around _emit that does most of the work and is used by all message passers (e.g. info, warning, etc.).

The MPI_RANK printout was removed because it’s obvious in the stdout now.

clearSingleWarnings()[source]

Reset the single warned list so we get messages again.

warningReport()[source]

Summarize all warnings for the run.

setVerbosity(levelInput)[source]

Sets the minimum output verbosity for the logger.

Any message with a higher verbosity than this will be emitted.

Parameters

levelInput (int or str) – The level to set the log output verbosity to. Valid numbers are 0-50 and valid strings are keys of _logLevels

Examples

>>> setVerbosity('debug') -> sets to 0
>>> setVerbosity(0) -> sets to 0
getVerbosity()[source]

Return the global runLog verbosity.

setStreams(stdout, stderr)[source]

Set the stdout and stderr streams to any stream object.

class armi.runLog.PrintLog(verbosity=50)[source]

Bases: armi.runLog.Log

Log that emits to stdout/stderr or file-based streams (for MPI workers) with print.

Build a log object

Parameters

verbosity (int) – if a msg verbosity is > this, it will be emitted. The default of 50 means only error messages will be emitted. This usually gets adjusted by user settings quickly after instantiation.

startLog(name)[source]

Initialize the streams when parallel processing

close()[source]

End use of the log. Concatenate if needed and restore defaults

concatenateLogs()[source]

Concatenate the armi run logs and delete them.

Should only ever be called by master.

class armi.runLog.PrintLogCombined(verbosity=50)[source]

Bases: armi.runLog.PrintLog

Print log that doesn’t break up into files

Build a log object

Parameters

verbosity (int) – if a msg verbosity is > this, it will be emitted. The default of 50 means only error messages will be emitted. This usually gets adjusted by user settings quickly after instantiation.

startLog(name)[source]

Initialize the streams when parallel processing

close()[source]

End use of the log. Concatenate if needed and restore defaults

concatenateLogs()[source]

Concatenate the armi run logs and delete them.

Should only ever be called by master.

armi.runLog.raw(msg)[source]

Print raw text without any special functionality.

armi.runLog.extra(msg, single=False, label=None)[source]
armi.runLog.debug(msg, single=False, label=None)[source]
armi.runLog.info(msg, single=False, label=None)[source]
armi.runLog.important(msg, single=False, label=None)[source]
armi.runLog.warning(msg, single=False, label=None)[source]
armi.runLog.error(msg, single=False, label=None)[source]
armi.runLog.header(msg, single=False, label=None)[source]
armi.runLog.flush()[source]

Flush LOG’s output in the err and output streams

armi.runLog.prompt(statement, question, *options)[source]

“Prompt the user for some information.

armi.runLog.warningReport()[source]
armi.runLog.setVerbosity(level)[source]
armi.runLog.getVerbosity()[source]
armi.runLog.logFactory()[source]

Create the default logging object.