PreformattedLogger

(class from pyomo.contrib.pyros.util)

class pyomo.contrib.pyros.util.PreformattedLogger(name, level=0)[source]

Bases: Logger

A specialized logger object designed to cast log messages to Pyomo Preformatted objects prior to logging the messages. Useful for circumventing the formatters of the standard Pyomo logger in the event an instance is a descendant of the Pyomo logger.

__init__(name, level=0)

Initialize the logger with a name and an optional level.

Methods

__init__(name[, level])

Initialize the logger with a name and an optional level.

addFilter(filter)

Add the specified filter to this handler.

addHandler(hdlr)

Add the specified handler to this logger.

callHandlers(record)

Pass a record to all relevant handlers.

critical(msg, *args, **kwargs)

Preformat and log msg % args with severity logging.CRITICAL.

debug(msg, *args, **kwargs)

Preformat and log msg % args with severity logging.DEBUG.

error(msg, *args, **kwargs)

Preformat and log msg % args with severity logging.ERROR.

exception(msg, *args[, exc_info])

Convenience method for logging an ERROR with exception information.

fatal(msg, *args, **kwargs)

Don't use this method, use critical() instead.

filter(record)

Determine if a record is loggable by consulting all the filters.

findCaller([stack_info, stacklevel])

Find the stack frame of the caller so that we can note the source file name, line number and function name.

getChild(suffix)

Get a logger which is a descendant to this one.

getEffectiveLevel()

Get the effective level for this logger.

handle(record)

Call the handlers for the specified record.

hasHandlers()

See if this logger has any handlers configured.

info(msg, *args, **kwargs)

Preformat and log msg % args with severity logging.INFO.

isEnabledFor(level)

Is this logger enabled for level 'level'?

log(level, msg, *args, **kwargs)

Preformat and log msg % args with integer severity level.

makeRecord(name, level, fn, lno, msg, args, ...)

A factory method which can be overridden in subclasses to create specialized LogRecords.

removeFilter(filter)

Remove the specified filter from this handler.

removeHandler(hdlr)

Remove the specified handler from this logger.

setLevel(level)

Set the logging level of this logger.

warn(msg, *args, **kwargs)

warning(msg, *args, **kwargs)

Preformat and log msg % args with severity logging.WARNING.

Attributes

manager

root

Member Documentation

addFilter(filter)

Add the specified filter to this handler.

addHandler(hdlr)

Add the specified handler to this logger.

callHandlers(record)

Pass a record to all relevant handlers.

Loop through all handlers for this logger and its parents in the logger hierarchy. If no handler was found, output a one-off error message to sys.stderr. Stop searching up the hierarchy whenever a logger with the “propagate” attribute set to zero is found - that will be the last logger whose handlers are called.

critical(msg, *args, **kwargs)[source]

Preformat and log msg % args with severity logging.CRITICAL.

debug(msg, *args, **kwargs)[source]

Preformat and log msg % args with severity logging.DEBUG.

error(msg, *args, **kwargs)[source]

Preformat and log msg % args with severity logging.ERROR.

exception(msg, *args, exc_info=True, **kwargs)

Convenience method for logging an ERROR with exception information.

fatal(msg, *args, **kwargs)

Don’t use this method, use critical() instead.

filter(record)

Determine if a record is loggable by consulting all the filters.

The default is to allow the record to be logged; any filter can veto this and the record is then dropped. Returns a zero value if a record is to be dropped, else non-zero.

Changed in version 3.2: Allow filters to be just callables.

findCaller(stack_info=False, stacklevel=1)

Find the stack frame of the caller so that we can note the source file name, line number and function name.

getChild(suffix)

Get a logger which is a descendant to this one.

This is a convenience method, such that

logging.getLogger(‘abc’).getChild(‘def.ghi’)

is the same as

logging.getLogger(‘abc.def.ghi’)

It’s useful, for example, when the parent logger is named using __name__ rather than a literal string.

getEffectiveLevel()

Get the effective level for this logger.

Loop through this logger and its parents in the logger hierarchy, looking for a non-zero logging level. Return the first one found.

handle(record)

Call the handlers for the specified record.

This method is used for unpickled records received from a socket, as well as those created locally. Logger-level filtering is applied.

hasHandlers()

See if this logger has any handlers configured.

Loop through all handlers for this logger and its parents in the logger hierarchy. Return True if a handler was found, else False. Stop searching up the hierarchy whenever a logger with the “propagate” attribute set to zero is found - that will be the last logger which is checked for the existence of handlers.

info(msg, *args, **kwargs)[source]

Preformat and log msg % args with severity logging.INFO.

isEnabledFor(level)

Is this logger enabled for level ‘level’?

log(level, msg, *args, **kwargs)[source]

Preformat and log msg % args with integer severity level.

makeRecord(name, level, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None)

A factory method which can be overridden in subclasses to create specialized LogRecords.

removeFilter(filter)

Remove the specified filter from this handler.

removeHandler(hdlr)

Remove the specified handler from this logger.

setLevel(level)

Set the logging level of this logger. level must be an int or a str.

warning(msg, *args, **kwargs)[source]

Preformat and log msg % args with severity logging.WARNING.