Module ncs.log
This module provides some logging utilities.
Functions
def init_logging(vmid, log_file, log_level)
-
Initialize logging
def log_datefmt()
-
Return date format used in logging.
def log_file()
-
Return log file used, if any else None
def log_format()
-
Return log format.
def log_handler()
-
Return log handler used, if any else None
def mk_log_formatter()
-
Create log formatter with log and date format setup
def reopen_logs()
-
Re-open log files if log handler is set
def set_log_level(vmid, log_level)
-
Set log level on the vmid logger and root logger
Classes
class Log (logobject, add_timestamp=False)
-
A log helper class.
This class makes it easier to write log entries. It encapsulates another log object that supports Python standard log interface, and makes it easier to format the log message be adding the ability to support multiple arguments.
Example
import logging import confd.log
logger = logging.getLogger(name) mylog = confd.log.Log(logger)
count = 3 name = 'foo' mylog.debug('got ', count, ' values from ', name)
Initialize a Log object.
The argument 'logobject' is mandatory and can be any object which should support as least one of the standard log methods (info, warning, error, critical, debug). If 'add_timestamp' is set to True a time stamp will precede your log message.
Methods
def critical(self, *args)
-
Log a critical message.
def debug(self, *args)
-
Log a debug message.
def error(self, *args)
-
Log an error message.
def fatal(self, *args)
-
Just calls critical().
def info(self, *args)
-
Log an information message.
def warning(self, *args)
-
Log a warning message.
class ParentProcessLogHandler (log_q)
-
A handler class which writes logging records, appropriately formatted, to a stream. Note that this class does not close the stream, as sys.stdout or sys.stderr may be used.
Initialize the handler.
If stream is not specified, sys.stderr is used.
Ancestors
Methods
def emit(self, record)
-
Emit log record by sending a pre-formatted record to the parent process