This class formats and displays log messages in Salome environment. More...
Public Member Functions | |
def | __init__ (self, keyword="KEY", level=salome.kernel.logconfig.loggingLevel, color=None, sourceFileName=None) |
def | showDebug (self) |
Log all messages, including DEBUG level messages (equivalent to setLevel(logging.DEBUG)). More... | |
def | setLogFile (self, logFilename) |
Define a log file to record the log messages (in addition to the standard output). More... | |
def | setColor (self, color) |
Set the color of log messages on color-capable terminals. More... | |
def | closeLogFile (self) |
Close the log file. More... | |
def | hideDebug (self) |
Hide DEBUG level messages (equivalent to setLevel(logging.INFO)). More... | |
Private Attributes | |
_baseFormatString | |
_baseFormatter | |
_stdoutStream | |
_stdoutHandler | |
_fileHandler | |
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::
def logger.Logger.__init__ | ( | self, | |
keyword = "KEY" , |
|||
level = salome.kernel.logconfig.loggingLevel , |
|||
color = None , |
|||
sourceFileName = None |
|||
) |
Reimplemented in logger.ExtLogger.
def logger.Logger.closeLogFile | ( | self | ) |
Close the log file.
References logger.Logger._fileHandler, and KERNEL_PY.kernel.logger.Logger._fileHandler.
Referenced by logger.Logger.setLogFile(), and KERNEL_PY.kernel.logger.Logger.setLogFile().
def logger.Logger.hideDebug | ( | self | ) |
Hide DEBUG level messages (equivalent to setLevel(logging.INFO)).
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.
References logger.Logger._baseFormatString, KERNEL_PY.kernel.logger.Logger._baseFormatString, logger.Logger._baseFormatter, KERNEL_PY.kernel.logger.Logger._baseFormatter, logger.Logger._stdoutHandler, KERNEL_PY.kernel.logger.Logger._stdoutHandler, logger.Logger._stdoutStream, KERNEL_PY.kernel.logger.Logger._stdoutStream, termcolor.canDisplayColor(), and termcolor.getControlSequence().
def logger.Logger.setLogFile | ( | self, | |
logFilename | |||
) |
Define a log file to record the log messages (in addition to the standard output).
References logger.Logger._baseFormatter, KERNEL_PY.kernel.logger.Logger._baseFormatter, logger.Logger._fileHandler, KERNEL_PY.kernel.logger.Logger._fileHandler, logger.Logger.closeLogFile(), and KERNEL_PY.kernel.logger.Logger.closeLogFile().
def logger.Logger.showDebug | ( | self | ) |
Log all messages, including DEBUG level messages (equivalent to setLevel(logging.DEBUG)).
|
private |
Referenced by logger.Logger.setColor(), and KERNEL_PY.kernel.logger.Logger.setColor().
|
private |
|
private |
|
private |
Referenced by logger.Logger.setColor(), and KERNEL_PY.kernel.logger.Logger.setColor().
|
private |
Referenced by logger.Logger.setColor(), and KERNEL_PY.kernel.logger.Logger.setColor().