saltsafelog

Module provides uniform logging for SALT.

class saltsafelog.SaltLog(logfile, with_stdout=True)

Class providing uniform logging.

error(e, with_backtrace=True, with_stdout=True)

Prints error message and backtrace to logfile.

message(m, with_header=True, with_stdout=True)

Prints message m to logfile.

warning(m, with_stdout=True)

Prints warning message m to logfile.

saltsafelog.history(level=3, wrap=True, wrapchar=80, exclude=[])

Return the history of the call. This includes return the name of the current program as well as the information about all the parameters which are passed to it. The return is the name of the program along witha string listing all the parameters

level – the level of the frame of interest wrap – wraps characters if true wrapchar–number of characters to wrap at exclude–options to exclude

returns str, str

saltsafelog.logging(*args, **kwds)

Context manager to ensure proper error handling and logging.

Example usage:

with logging('logfile.txt') as log:
    # User code
    log.message('Hello world!') # Writes a message to the log
    # Some more user code
    log.warning('This is a warning message') # Writes warning
    # Again some user code
    raise SaltError('Oops!') # Error message and traceback are written to log

Previous topic

saltsafeio

Next topic

saltstat

This Page