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

# @(#) $Id: ACSHandler.py,v 1.2 2012/03/09 14:31:49 acaproni Exp $
#
#    ALMA - Atacama Large Millimiter Array
#    (c) Associated Universities, Inc. Washington DC, USA,  2001
#    (c) European Southern Observatory, 2002
#    Copyright by ESO (in the framework of the ALMA collaboration)
#    and Cosylab 2002, All rights reserved
#
#    This library is free software; you can redistribute it and/or
#    modify it under the terms of the GNU Lesser General Public
#    License as published by the Free Software Foundation; either
#    version 2.1 of the License, or (at your option) any later version.
#
#    This library is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#    Lesser General Public License for more details.
#
#    You should have received a copy of the GNU Lesser General Public
#    License along with this library; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

 
Modules
       
ACSLog
omniORB.CORBA
abc
logging
posixpath
sched
string
sys
threading

 
Classes
       
__builtin__.object
LogThrottle
logging.Formatter(__builtin__.object)
ACSFormatter
logging.LogRecord(__builtin__.object)
ACSLogRecord
logging.handlers.BufferingHandler(logging.Handler)
ACSHandler

 
class ACSFormatter(logging.Formatter)
    This trivial helper class is used to automate setting up the way logs are
printed.
 
 
Method resolution order:
ACSFormatter
logging.Formatter
__builtin__.object

Methods defined here:
__init__(self)
Constructor.
format(self, record)
Overload.

Methods inherited from logging.Formatter:
formatException(self, ei)
Format and return the specified exception information as a string.
 
This default implementation just uses
traceback.print_exception()
formatTime(self, record, datefmt=None)
Return the creation time of the specified LogRecord as formatted text.
 
This method should be called from format() by a formatter which
wants to make use of a formatted time. This method can be overridden
in formatters to provide for any specific requirement, but the
basic behaviour is as follows: if datefmt (a string) is specified,
it is used with time.strftime() to format the creation time of the
record. Otherwise, the ISO8601 format is used. The resulting
string is returned. This function uses a user-configurable function
to convert the creation time to a tuple. By default, time.localtime()
is used; to change this for a particular formatter instance, set the
'converter' attribute to a function with the same signature as
time.localtime() or time.gmtime(). To change it for all formatters,
for example if you want all logging times to be shown in GMT,
set the 'converter' attribute in the Formatter class.
usesTime(self)
Check if the format uses the creation time of the record.

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

Data and other attributes inherited from logging.Formatter:
converter = <built-in function localtime>
localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
                          tm_sec,tm_wday,tm_yday,tm_isdst)
 
Convert seconds since the Epoch to a time tuple expressing local time.
When 'seconds' is not passed in, convert the current time instead.

 
class ACSHandler(logging.handlers.BufferingHandler)
    Class ACSHandler is a BufferingHandler subclass which sends log messages to
the (CORBA) ACS Log Svc. If the CORBA logging service is unavailable the log
message will be saved and the handler will try to publish the log next time
provided the buffer has not reached full capacity. If the buffer is full and
the logging service is still unavailable, the buffer is reset and the log
messages are lost from this handlers perspective.
 
 
Method resolution order:
ACSHandler
logging.handlers.BufferingHandler
logging.Handler
logging.Filterer
__builtin__.object

Methods defined here:
__init__(self, capacity=1000, dispatchlevel=51, batchsize=10)
Constructor.
 
Parameters:
    capacity - the maximum size of the log cache.
    dispatchlevel - level of message that should be immediately sent
    batchsize - the number of log records to be held before sending
    flushinterval - maximum period that a message can wait in the send queue
configureLogging(self, maxLogPerTimeInterval, alarmSender=None)
Configure the logging
 
maxLogPerTimeInterval: Max number of logs per second (see logThrottle)
logThrottleAlarmSender: to raise/clear alarms from thelogThrottle
 
if alarmSender is not None, it must be a subclass of LogThrottleAlarmerBase
emit(self, record)
Overridden.
 
Append the record. If shouldFlush() tells us to, call flush() to process
the buffer.
flush(self)
Overridden
flushToFile(self, record)
Helper method.
Sends a single record to file.
 
Parameters:
    - record a Logging record
    
Returns: Nothing
 
Raises: ???
getCORBALogger(self)
If the CORBA logging service is up and running, returns a reference to
it. Otherwise, returns None.
initFileHandler(self)
Helper method initializes the file handler
replaceOldRecord(self, record)
#--------------------------------------------------------------------------
sendLog(self, record)
Method which sends logs to the real ACS logging service.
shouldFlush(self, record)
Overridden.
 
This method returns true if the number of pending records exceeds
the batchsize or if the new record matches or exceeds the immediate
dispatch priority.

Methods inherited from logging.handlers.BufferingHandler:
close(self)
Close the handler.
 
This version just flushes and chains to the parent class' close().

Methods inherited from logging.Handler:
acquire(self)
Acquire the I/O thread lock.
createLock(self)
Acquire a thread lock for serializing access to the underlying I/O.
format(self, record)
Format the specified record.
 
If a formatter is set, use it. Otherwise, use the default formatter
for the module.
get_name(self)
handle(self, record)
Conditionally emit the specified logging record.
 
Emission depends on filters which may have been added to the handler.
Wrap the actual emission of the record with acquisition/release of
the I/O thread lock. Returns whether the filter passed the record for
emission.
handleError(self, record)
Handle errors which occur during an emit() call.
 
This method should be called from handlers when an exception is
encountered during an emit() call. If raiseExceptions is false,
exceptions get silently ignored. This is what is mostly wanted
for a logging system - most users will not care about errors in
the logging system, they are more interested in application errors.
You could, however, replace this with a custom handler if you wish.
The record which was being processed is passed in to this method.
release(self)
Release the I/O thread lock.
setFormatter(self, fmt)
Set the formatter for this handler.
setLevel(self, level)
Set the logging level of this handler.
set_name(self, name)

Data descriptors inherited from logging.Handler:
name

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)

 
class ACSLogRecord(logging.LogRecord)
    This class extends the regular LogRecord information to capture
specific information for ACS.
 
 
Method resolution order:
ACSLogRecord
logging.LogRecord
__builtin__.object

Methods defined here:
__init__(self, name, level, pathname, lineno, msg, args, exc_info, func=None)

Methods inherited from logging.LogRecord:
__str__(self)
getMessage(self)
Return the message for this LogRecord.
 
Return the message for this LogRecord after merging any user-supplied
arguments with the message.

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

 
class LogThrottle(__builtin__.object)
    Process level throttle for logs.
 
  Methods defined here:
__init__(self, maxLogPerInterval)
Initializes the Throttle
 
Parameters:
    The max number of logs/s
checkPublishLogRecord(self)
Checks whether the log throttle allows logging a record. 
No exception or other action beyond the returned boolean.
 
Returns: True if a record can be logged, False otherwise.
configureLogging(self, maxLogPerInterval)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
gethostname(...)
gethostname() -> string
 
Return the current host name.
getpid(...)
getpid() -> pid
 
Return the current process id
gmtime(...)
gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,
                       tm_sec, tm_wday, tm_yday, tm_isdst)
 
Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.
GMT).  When 'seconds' is not passed in, convert the current time instead.
makeACSLogRecord(name, level, fn, lno, msg, args, exc_info, func=None, extra=None)
Build the ACSLogRecord for this information.
sleep(...)
sleep(seconds)
 
Delay execution for a given number of seconds.  The argument may be
a floating point number for subsecond precision.
time(...)
time() -> floating point number
 
Return the current time in seconds since the Epoch.
Fractions of a second may be present if the system clock provides them.

 
Data
        DEFAULT_IMMEDIATE_DISPATCH = 51
DEFAULT_MAXIMUM_QUEUE = 1000
DEFAULT_RECORD_CAPACITY = 10
LEVELS = {'CRITICAL': ACS_LOG_CRITICAL, 'DEBUG': ACS_LOG_DEBUG, 'ERROR': ACS_LOG_ERROR, 'INFO': ACS_LOG_INFO, 'NOTSET': ACS_LOG_TRACE, 'WARN': ACS_LOG_WARNING, 'WARNING': ACS_LOG_WARNING}
LOG_FILE_NAME = '/alma/ACS-2016.6/acsdata/tmp/v6r201606-r6/acs_local_log_pydoc_14132'
NO_AUDIENCE = ''
__revision__ = '$Id: ACSHandler.py,v 1.2 2012/03/09 14:31:49 acaproni Exp $'
environ = {'ACS_CDB': '/alma/ACS-2016.6/acsdata/config/def....spx=38;5;45:*.xspf=38;5;45:', 'USER': 'almamgr'}
with_statement = _Feature((2, 5, 0, 'alpha', 1), (2, 6, 0, 'alpha', 0), 32768)