armi.runLog module

This module handles logging of console during a simulation.

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: Filter

Important logging filter.

  • allow users to turn off duplicate warnings

  • handles special indentation rules for our logs

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

Bases: Logger

Custom Logger to support our specific desires.

  1. Giving users the option to de-duplicate warnings

  2. Piping stderr to a log file

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.

This 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: 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.

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

Ensure this STAYS a null logger.

armi.runLog.createLogDir(logDir: Optional[str] = None) None[source]

A helper method to create the log directory.

armi.runLog.logFactory()[source]

Create the default logging object.