Version: 8.3.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
logger.Logger Class Reference

This class formats and displays log messages in Salome environment. More...

Inheritance diagram for logger.Logger:
Inheritance graph

Public Member Functions

def __init__
 
def showDebug
 Log all messages, including DEBUG level messages (equivalent to setLevel(logging.DEBUG)). More...
 
def setLogFile
 Define a log file to record the log messages (in addition to the standard output). More...
 
def setColor
 Set the color of log messages on color-capable terminals. More...
 
def closeLogFile
 Close the log file. More...
 
def hideDebug
 Hide DEBUG level messages (equivalent to setLevel(logging.INFO)). More...
 
def fatal
 Log a message with CRITICAL level. More...
 

Detailed Description

This class formats and displays log messages in Salome environment.

It inherits logging.Logger class defined in logging module from Python library, so all methods from logging.Logger can be used here. The format of the traces is: LEVEL[keyword] : Message

,where LEVEL is the level of the message (DEBUG, INFO, etc.), keyword is the name of the logger, and Message is the message to log.

When creating a new Logger object, the parameter keyword defines the name of the logger, level defines the logging level (default is logging.DEBUG if KERNEL module is configured with –enable-debug option or logging.WARNING otherwise), and color defines the color of the log messages for this logger (log messages will appear in color only when displayed on color - capable ASCII terminals). See module salome.kernel.termcolor for the color constants.

By default, log messages will be displayed only on standard output. They can also be recorded in a file (see method setLogFile()). For now, the CORBA-based logging facility can not be used through this class.

A source filename sourceFileName can be defined. If this argument is specified, then the keyword is modified to the basename of the sourceFileName

Basic usage::

1 from salome.kernel.logger import Logger
2 log = Logger("Test")
3 log.debug("Debug message")
4 log.info("Information message")
5 log.warning("Warning message")
6 log.error("Error message")
7 log.critical("Fatal error message")

Member Function Documentation

def logger.Logger.showDebug (   self)

Log all messages, including DEBUG level messages (equivalent to setLevel(logging.DEBUG)).

def logger.Logger.setLogFile (   self,
  logFilename 
)

Define a log file to record the log messages (in addition to the standard output).

def logger.Logger.setColor (   self,
  color 
)

Set the color of log messages on color-capable terminals.

If color is None, the default color will be used.

def logger.Logger.closeLogFile (   self)

Close the log file.

def logger.Logger.hideDebug (   self)

Hide DEBUG level messages (equivalent to setLevel(logging.INFO)).

def logger.Logger.fatal (   self,
  message 
)

Log a message with CRITICAL level.

This method only exists for backward compatibility and is equivalent to critical(message).