armi.runLog module

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

The default way of calling and the global armi logger is to just import it:

from armi import runLog

You may want a logger specific to a single module, say to provide debug logging for only one module. That functionality is provided by a global override of logging imports:

import logging
runLog = logging.getLogger(__name__)

In either case, you can then log things the same way:

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

Or change the log level the same way:

runLog.setVerbosity('debug')
armi.runLog.close(mpiRank=None)[source]

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

armi.runLog.concatenateLogs(logDir=None)[source]

Concatenate the armi run logs and delete them.

Should only ever be called by parent.

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.warningReport()[source]
armi.runLog.setVerbosity(level)[source]
armi.runLog.getVerbosity()[source]
class armi.runLog.DeduplicationFilter(*args, **kwargs)[source]

Bases: logging.Filter

Important logging filter

  • allow users to turn off duplicate warnings

  • handles special indentation rules for our logs

Initialize a filter.

Initialize with the name of the logger which, together with its children, will have its events allowed through the filter. If no name is specified, allow every event.

filter(record)[source]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class armi.runLog.RunLogger(*args, **kwargs)[source]

Bases: logging.Logger

Custom Logger to support:

  1. Giving users the option to de-duplicate warnings

  2. Piping stderr to a log file

Initialize the logger with a name and an optional level.

FMT = '%(levelname)s%(message)s'
log(msgType, msg, single=False, label=None, **kwargs)[source]

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

In this situation, we do the mangling needed to get the log level to the correct number. And we do some custom string manipulation so we can handle de-duplicating warnings.

allowStopDuplicates()[source]

helper method to allow us to safely add the deduplication filter at any time

write(msg, **kwargs)[source]

the redirect method that allows to do stderr piping

flush(*args, **kwargs)[source]

stub, purely to allow stderr piping

close()[source]

helper method, to shutdown and delete a Logger

getDuplicatesFilter()[source]

This object should have a no-duplicates filter. If it exists, find it.

warningReport()[source]

Summarize all warnings for the run.

setVerbosity(intLevel)[source]

A helper method to try to partially support the local, historical method of the same name

class armi.runLog.NullLogger(name, isStderr=False)[source]

Bases: armi.runLog.RunLogger

This is really just a placeholder for logging before or after the span of a normal armi run. It will forward all logging to stdout/stderr, as you’d normally expect. But it will preserve the formatting and duplication tools of the armi library.

Initialize the logger with a name and an optional level.

addHandler(*args, **kwargs)[source]

ensure this STAYS a null logger

armi.runLog.logFactory()[source]

Create the default logging object.