Acspy.Common.Log
index
/alma/ACS-2016.6/ACSSW/lib/python/site-packages/Acspy/Common/Log.py

An interface to logging services, including the ACS Log Server.
 
This module is designed to be used in all Python code, and to be
failsafe, so that users can rely on getting logging output in (nearly)
all circumstances.Design choices derived from the design goals:
1) in the absence of the ACS Log Server to provide logging to a file
similar to the standard ACS logging functionality, 2) in case of
failure to log to a file, to log to stderr. Failure to log
to stderr will cause an exception; I think this effect is desirable,
but may change if I'm persuaded otherwise.
 
Logging also respects the "ACS_LOG_STDOUT" and "ACS_LOG_CENTRAL" environment
variables.
 
Last but not least, developers should use the getLogger() function instead
of creating new instances of the Logger class which can take a very long
time depending on managers load.

 
Modules
       
ACSLog
Logging
abc
logging
math
os
sched
sys
threading
time

 
Classes
       
logging.Logger(logging.Filterer)
Logger

 
class Logger(logging.Logger)
    Logger is of primary interest to developers. It is used to send log
messages to the ACS Logging System. Developers need not create an instance
of this class though as the getLogger() function returns a singled logger.
 
 
Method resolution order:
Logger
logging.Logger
logging.Filterer
__builtin__.object

Methods defined here:
__init__(self, name)
Create a Logger instance.
 
Parameters: name of this logger
 
Returns: Nothing
 
Raises: Nothing
acsLog(self, level, msg, *args, **kwargs)
This method defines the ACS log method, used to include extra functionality
like the statistics module
 
Parameters:  level of the message and message itself
 
Returns:  Nothing
 
Raises:  Nothing
closeLogger(self)
This method is called when the logger is to be closed and will activate any final action
the logger need to perform before liberating resources.
The only task currently to be performed is to print out final statistics of the logger
 
Parameters:  Nothing
 
Returns:  Nothing
 
Raises:  Nothing
configureLogging(self, maxLogsPerSec, alarmSender=None)
If alarmSender is not None, it must be a subclass of LogThrottleAlarmerBase
See also ACSHandler.configureLogging
findCaller(self)
Find the stack frame of the caller so that we can note the source
file name, line number and function name.
getLevels(self)
Return the current priority level values for the stdout and central logs.
 
Parameter: None
 
Returns: Logging.LoggingConfigurable.LogLevels object containing the current level settings
 
Raises: Nothing
logAlert(self, msg)
Log an alert message.
 
Parameters:
- msg is a string to be sent to the logging system
 
Returns: Nothing
 
Raises: Nothing
logAtLevel(self, lvl, msg)
Log a message at the given level.
 
Parameters:
- lvl is the log level to send the message at
- msg is a string to be sent to the logging system
 
Returns: Nothing
 
Raises: ValueError if lvl is NOTSET or OFF
logCritical(self, msg)
Log a critical message.
 
Parameters:
- msg is a string to be sent to the logging system
 
 
Returns: Nothing
 
Raises: Nothing
logDebug(self, msg)
Log a debug message.
 
Parameters:
- msg is a string to be sent to the logging system
 
 
Returns: Nothing
 
Raises: Nothing
logDelouse(self, msg)
Log a delouse message.
 
Parameters:
- msg is a string to be sent to the logging system
 
 
Returns: Nothing
 
Raises: Nothing
logEmergency(self, msg)
Log an emergency message.
 
Parameters:
- msg is a string to be sent to the logging system
 
 
Returns: Nothing
 
Raises: Nothing
logError(self, msg)
Log an error message.
 
Parameters:
- msg is a string to be sent to the logging system
 
 
Returns: Nothing
 
Raises: Nothing
logErrorTrace(self, errortrace, priority=ACS_LOG_ERROR)
Log an error stack trace.
 
Parameter:
- errortrace (top of error stack)
- priorty value of logging priorty
 
Returns: Nothing
 
Raises: KeyError if priority is not in the ACSLog.Priorities
logInfo(self, msg)
Log an informational message.
 
Parameters:
- msg is a string to be sent to the logging system
 
 
Returns: Nothing
 
Raises: Nothing
logNotSoTypeSafe(self, priority, msg, audience=None, array=None, antenna=None)
Log a message indicating audience, array and/or antenna.
 
Parameter:
- priority value of logging priority
- msg log definition shortDescription
- audience
- array
- antenna
 
Returns: Nothing
 
Raises: KeyError if priority is not in the ACSLog.Priorities
logNotice(self, msg)
Log a notice message.
 
Parameters:
- msg is a string to be sent to the logging system
 
 
Returns: Nothing
 
Raises: Nothing
logTrace(self, msg)
Log a trace message.
 
Parameters:
- msg is a string to be sent to the logging system
 
 
Returns: Nothing
 
Raises: Nothing
logTypeSafe(self, priority, timestamp, msg, rtCont, srcInfo, data, audience=None, array=None, antenna=None)
Log a type safe log.
 
Parameter:
- priority value of logging priority
- timestamp time of log creation
- msg log definition shortDescription
- rtCont run-time context information
- srcInfo src information
- data name/value pairs
 
Returns: Nothing
 
Raises: KeyError if priority is not in the ACSLog.Priorities
logWarning(self, msg)
Log a warning message.
 
Parameters:
- msg is a string to be sent to the logging system
 
Returns: Nothing
 
Raises: Nothing
logXML(self, xml)
Log an XML string.
 
Parameter:
xml - XML string (really just any string, but the log server
may not like anything non-XMLish -- I have not
tried this)
 
Returns: Nothing
 
Raises: Nothing
makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None)
Build the ACSLogRecord for this information
setLevels(self, loglevel)
Adjust the priority level filter for log messages.
 
Parameter:
- Logging.LoggingConfigurable.LogLevels object containing new level information
 
Returns: Nothing
 
Raises: Nothing

Methods inherited from logging.Logger:
addHandler(self, hdlr)
Add the specified handler to this logger.
callHandlers(self, 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(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'CRITICAL'.
 
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
 
logger.critical("Houston, we have a %s", "major disaster", exc_info=1)
debug(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'DEBUG'.
 
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
 
logger.debug("Houston, we have a %s", "thorny problem", exc_info=1)
error(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'ERROR'.
 
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
 
logger.error("Houston, we have a %s", "major problem", exc_info=1)
exception(self, msg, *args, **kwargs)
Convenience method for logging an ERROR with exception information.
fatal = critical(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'CRITICAL'.
 
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
 
logger.critical("Houston, we have a %s", "major disaster", exc_info=1)
getChild(self, 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(self)
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(self, 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.
info(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'INFO'.
 
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
 
logger.info("Houston, we have a %s", "interesting problem", exc_info=1)
isEnabledFor(self, level)
Is this logger enabled for level 'level'?
log(self, level, msg, *args, **kwargs)
Log 'msg % args' with the integer severity 'level'.
 
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
 
logger.log(level, "We have a %s", "mysterious problem", exc_info=1)
removeHandler(self, hdlr)
Remove the specified handler from this logger.
setLevel(self, level)
Set the logging level of this logger.
warn = warning(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'WARNING'.
 
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
 
logger.warning("Houston, we have a %s", "bit of a problem", exc_info=1)
warning(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'WARNING'.
 
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
 
logger.warning("Houston, we have a %s", "bit of a problem", exc_info=1)

Data and other attributes inherited from logging.Logger:
manager = <logging.Manager object>
root = <logging.RootLogger object>

Methods inherited from logging.Filterer:
addFilter(self, filter)
Add the specified filter to this handler.
filter(self, 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.
removeFilter(self, filter)
Remove the specified filter from this handler.

Data descriptors inherited from logging.Filterer:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
acsPrintExcDebug()
Basically identical to traceback.print_exc() only one small exception -
exception information is only printed to stdout of the ACS logging level
is set to DEBUG or lower.
delay(remaining)
Pause before checking if the next event should be processed.
 
Parameter:
- remaining is the number of seconds to wait before the next event.
doesLoggerExist(key_name)
This method determines if a logger exists for the given name.
 
Parameters:  name of the logger being queried
 
Returns:  True if named logger already exists.
 
Raises:  Nothing
flush()
Flush the messages from the buffer and schedule the next event.
 
Returns:  Nothing
 
Raises: Nothing
getDefaultLevels()
Retrive the current default log levels
 
Parameters:  None
 
Returns: LogLevels object containing the current default log levels.
 
Raises: NameError if no Logger object has been previously instantiated
getLevelName(lnum)
#------------------------------------------------------------------------------
getLogger(name=None)
This returns the singleton instance of logger.
 
Used so we do not have to keep asking the slow manager for a reference to
the logging service.
 
Parameters: name of the logger
 
Return: A logger
 
Raises: ???
getLoggerNames(startfilter=None)
This returns a list of defined known loggers.
 
Used to support the LoggingConfigurable method get_logger_names.
 
Parameters:  a string containing the beginning of the names to be returned. 
 
Returns: A list of logger name strings
 
Raises:  Nothing
gethostname(...)
gethostname() -> string
 
Return the current host name.
isFlushRunning()
Is the flush thread running?
 
Returns: the state of the flush thread or False if thread has not been
         created.
 
Raises:  Nothing
setBatchSize(batchsize)
Set the batch size for the central log queue.  Batch size cannot
exceed the capacity.
 
Parameters:
- batchsize is the new number of records to be sent as a group.
 
Returns: Nothing
 
Raises: NameError if no Logger object has been previously instantiated
setCapacity(capacity)
Set the maximum capacity for the central log queue.
 
Parameters:
- capacity is the new maximum number of pending records
 
Returns: Nothing
 
Raises: NameError if no Logger object has been previously instantiated
setDefaultLevels(levels)
Set the default log level filtering for this process.
 
Parameters:
- level is the LogLevels object containing the new values
 
Returns:  Nothing
 
Raises: NameError if no Logger object has been previously instantiated
setFlushInterval(interval)
Change the period between flushes.
 
Parameter:
- interval is the number of seconds between flushes
 
Return:  Nothing
 
Raise:  Nothing
setImmediateDispatchLevel(level)
Set the immediate dispatch threshold for the central log queue.
 
Parameters:
- level is the new level that triggers immediate flushing of the queue.
 
Returns: Nothing
 
Raises: KeyError if level is not defined
        NameError if no Logger object has been previously instantiated
startPeriodicFlush(interval=10)
Configure and start the periodic flush thread.  
 
Parameter:
- interval is the number of seconds between flushes
 
Returns:  Nothing
 
Raises:  Nothing
stdoutOk(log_priority)
Helper method returns true if log_priority is greater than $ACS_LOG_STDOUT.
stopPeriodicFlush()
Stop the periodic flush thread.
 
Returns:  Nothing
 
Raises:  Nothing

 
Data
        ACS_LOG_CENTRAL = 3
ACS_LOG_STDOUT = 3
CENTRALHANDLER = <Acspy.Common.ACSHandler.ACSHandler object>
DEFAULTCENTRALHANDLER = <logging.handlers.MemoryHandler object>
DEFAULTLOCALHANDLER = <logging.handlers.MemoryHandler object>
DEFAULT_FLUSH_PERIOD = 10
FLUSHTHREAD = None
INTERVAL = None
LEVELS = {0: 0, 1: 1, 2: 2, 3: 10, 4: 20, 5: 21, 6: 30, 7: 40, 8: 40, 9: 50, ...}
LOCALHANDLER = <logging.StreamHandler object>
NEXTEVENT = None
RLEVELS = {0: 0, 1: 1, 2: 2, 10: 3, 20: 4, 21: 5, 30: 6, 40: 8, 50: 9, 51: 10, ...}
SCHEDULER = None
__revision__ = '$Id: Log.py,v 1.3 2012/04/23 22:46:03 javarias Exp $'
environ = {'ACS_CDB': '/alma/ACS-2016.6/acsdata/config/def....spx=38;5;45:*.xspf=38;5;45:', 'USER': 'almamgr'}