本文整理汇总了Python中Acspy.Common.Log类的典型用法代码示例。如果您正苦于以下问题:Python Log类的具体用法?Python Log怎么用?Python Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shutdown
def shutdown(self, action):
'''
Shutdown the Container.
Normally invoked via CORBA but can also "self terminate" so to speak.
Parameters:
- action is an encrypted value that tells the container what action to take
oneway void shutdown (in unsigned long action)
'''
action = (action >> 8) & 0xFF
if (action == ACTIVATOR_EXIT) or (action == ACTIVATOR_REBOOT) or (action == ACTIVATOR_RELOAD):
self.logger.logTrace("Shutting down container: " + self.name)
#Logout from manager
ACSCorba.getManager().logout(self.token.h)
if (action == ACTIVATOR_REBOOT) or (action == ACTIVATOR_RELOAD):
print "Container.shutdown(): Action may not work correctly...-", str(action)
self.__init__(self.name)
else:
#tell the main thread of execution to stop
self.running = 0
Log.stopPeriodicFlush()
else:
self.logger.logWarning("Unable to process 'shutdown' request at this time: " + str(action))
# Close the alarm interface factory
Acsalarmpy.AlarmSystemInterfaceFactory.done()
示例2: testLoggerDefault
def testLoggerDefault(self):
"""SeveralLoggerCheck Levels changes on all loggers using default level"""
Log.setDefaultLevels(maci.LoggingConfigurable.LogLevels(False,4, 5))
self.assertEquals(True, self.plogger.usingDefault)
self.assertEquals(True, self.clogger.usingDefault)
self.assertEquals(Log.DEFAULTLOCALHANDLER.level, self.plogger.stdouthandler.level)
self.assertEquals(Log.DEFAULTCENTRALHANDLER.level, self.plogger.acshandler.level)
self.assertEquals(Log.DEFAULTLOCALHANDLER.level, self.clogger.stdouthandler.level)
self.assertEquals(Log.DEFAULTCENTRALHANDLER.level, self.plogger.acshandler.level)
示例3: testCycleStartStop
def testCycleStartStop(self):
"""PeriodicFlushCheck flushing thread start and stops correctly."""
Log.startPeriodicFlush()
self.assertEqual(Log.DEFAULT_FLUSH_PERIOD, Log.INTERVAL)
self.assertEqual(True, isinstance(Log.SCHEDULER, sched.scheduler))
self.assertEqual(True, isinstance(Log.FLUSHTHREAD, threading.Thread))
self.assertEqual(True, Log.FLUSHTHREAD.isAlive())
self.assertEqual(False, Log.NEXTEVENT is None)
Log.stopPeriodicFlush()
self.assertEqual(False, Log.FLUSHTHREAD.isAlive())
示例4: set_default_logLevels
def set_default_logLevels(self, levels): # pragma: NO COVER
'''
Set the default log level for this container.
Parameter:
levels - maci.LoggingConfigurable.LogLevels instance containing default log level values
Raises: Nothing
'''
Log.setDefaultLevels(levels)
示例5: set_logLevels
def set_logLevels(self, logger_name, levels):
"""
Set the default log level for this component.
Parameter:
logger_name - name of the component's logger
levels - maci.LoggingConfigurable.LogLevels instance containing default log level values
Raises: LoggerDoesNotExistExImpl if the logger is not active.
"""
if Log.doesLoggerExist(logger_name):
Log.getLogger(logger_name).setLevels(levels)
else:
raise LoggerDoesNotExistExImpl()
示例6: get_logLevels
def get_logLevels(self, logger_name):
"""
Retrieve the log levels for a given component.
Parameter:
logger_name - name of the component's logger
Returns: maci.LoggingConfigurable.LogLevels instance containing the logger's log level values
Raises: LoggerDoesNotExistExImpl if the logger is not active.
"""
if Log.doesLoggerExist(logger_name):
return Log.getLogger(logger_name).getLevels()
else:
raise LoggerDoesNotExistExImpl()
示例7: testCreation
def testCreation(self):
"""PeriodicFlushCheck is correct and consistent after import."""
if not Log.isFlushRunning():
self.assertEqual(True, Log.FLUSHTHREAD is None)
self.assertEqual(True, Log.SCHEDULER is None)
self.assertEqual(True, Log.NEXTEVENT is None)
self.assertEqual(True, Log.INTERVAL is None)
示例8: get_logger_names
def get_logger_names(self): # pragma: NO COVER
'''
Retrieve the names of the currently active loggers
Returns: list of logger name strings
'''
return Log.getLoggerNames()
示例9: configureComponentLogger
def configureComponentLogger(self, name):
'''
Configure the logger for the given component name from the values in the CDB.
Parameters:
name is the name of the component
'''
# Each component has an associated logger instance
clogger = Log.getLogger(name)
# Default levels are used for missing values
defaultlevels = Log.getDefaultLevels()
try:
#Get the global unnamed logging config to retrieve the maxLogsPerSecond attribute
logconfigG = self.cdbAccess.getElement("MACI/Containers/" + self.name + "/LoggingConfig", "LoggingConfig")
maxLogsPerSec = int(logconfigG[0]['maxLogsPerSecond'])
except (Exception):
# No value was supplied so default is used
maxLogsPerSec = -1
try:
# Process all the named logger configurations
logconfig = self.cdbAccess.getElement("MACI/Containers/" + self.name + "/LoggingConfig", "LoggingConfig/log:_")
for cfg in logconfig:
if cfg["Name"] == name:
try:
centrallevel = int(cfg['minLogLevel'])
except KeyError:
# No value was supplied so default is used
centrallevel = defaultlevels.minLogLevel
try:
locallevel = int(cfg['minLogLevelLocal'])
except KeyError:
# No value was supplied so default is used
locallevel = defaultlevels.minLogLevelLocal
clogger.setLevels(maci.LoggingConfigurable.LogLevels(False, centrallevel, locallevel))
clogger.configureLogging(maxLogsPerSec)
# There should only be one entry per logger so we are done
break
else:
# No matching named logger was found so the default values are used
clogger.setLevels(maci.LoggingConfigurable.LogLevels(True, 0, 0))
except Exception:
# No named loggers were defined so the default values are used
clogger.setLevels(maci.LoggingConfigurable.LogLevels(True, 0, 0))
示例10: testNestedOutput
def testNestedOutput(self):
"""SeveralLoggerCheck messages are logged only once for nested loggers"""
nlogger = Log.getLogger("MyLogger1.child")
before = len(Log.CENTRALHANDLER.buffer)
nlogger.logInfo("Nested Message")
after = len(Log.CENTRALHANDLER.buffer)
self.assertEqual(1, after - before)
Log.CENTRALHANDLER.buffer = []
示例11: testSetFlushInterval
def testSetFlushInterval(self):
"""PeriodicFlushCheck updates flush interval correctly"""
Log.startPeriodicFlush()
now = time.time()
next = Log.NEXTEVENT
Log.setFlushInterval(5)
self.assertNotEqual(next, Log.NEXTEVENT)
self.assertAlmostEqual(now + Log.INTERVAL, Log.NEXTEVENT[0],1)
Log.stopPeriodicFlush()
Log.setFlushInterval(Log.DEFAULT_FLUSH_PERIOD)
示例12: get_default_logLevels
def get_default_logLevels(self): # pragma: NO COVER
'''
Retrieve the default log levels used in this container.
Returns: maci.LoggingConfigurable.LogLevels instance containing default log level values
Raises: Nothing
'''
return Log.getDefaultLevels()
示例13: __init__
def __init__(self, sourceName = None, hostName = None):
"""
Create an instance of the AlarmSystemInterface.
Parameters: sourceName is the name of this source
hostName is the name of the computer where the source is running.
"""
self.logger = Log.getLogger()
self.sourceName = sourceName
self.hostName = hostName
self.configuration = ASI.ASIConfiguration()
示例14: testDoubleStart
def testDoubleStart(self):
"""PeriodicFlushCheck only one thread is created if start is called twice."""
Log.startPeriodicFlush()
ft = Log.FLUSHTHREAD
sc = Log.SCHEDULER
ne = Log.NEXTEVENT
Log.startPeriodicFlush()
self.assertEqual(ft, Log.FLUSHTHREAD)
self.assertEqual(sc, Log.SCHEDULER)
self.assertEqual(ne, Log.NEXTEVENT)
Log.stopPeriodicFlush()
示例15: setUp
def setUp(self):
self.pname = "MyLogger1"
self.plogger = Log.getLogger(self.pname)
self.cname = "MyLogger2"
self.clogger = Log.getLogger(self.cname)