本文整理汇总了Python中log4py.Logger类的典型用法代码示例。如果您正苦于以下问题:Python Logger类的具体用法?Python Logger怎么用?Python Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: User
class User(StateNode):
STATE_ACTIVE = 'Active'
def __init__( self, name, parent ):
StateNode.__init__( self, name, parent, initialState = self.STATE_ACTIVE )
self.log = Logger().get_instance( self.__class__.__name__ )
self.dialogs = {}
def identifyEvent( self, event ):
self.log.info( str(event) )
if isinstance( event, MessageEvent ):
return event.id
elif isinstance( event, StateChangeNotification ):
if event.node in self.dialogs.itervalues():
return 'Dialog' + event.node.currentState
raise SipException( '[' + str(self.name) + '] ' + 'Ignoring event ' + str(event) + '.' )
def inActive_onRxRequest( self, event ):
callid = event.message['Call-ID']
if not callid in self.dialogs:
dialog = Dialog( callid, self, event )
dialog.addListener( self )
self.dialogs[callid] = dialog
#FIXME: We don't really want to create a dialog for everything (e.g. REGISTER).
# Even if we create a dummy dialog, then the subscribe and register dialogs would conflict.
dialog = self.dialogs[callid]
self.send( event, dialog, False )
def inActive_onRxResponse( self, event ):
callid = event.message['Call-ID']
if not callid in self.dialogs:
self.handled = True
raise SipException( 'Dialog, ' + str(callid) + ' not found in user, ' + str(self.name) + '.' )
else:
dialog = self.dialogs[callid]
self.send( event, dialog, False )
def inActive_onTxRequest( self, event ):
self.notify( event, False )
def inActive_onTxResponse( self, event ):
self.notify( event, False )
def inActive_onDialogEarly( self, event ):
#FIXME:
self.inActive_onDialogProceeding( self, event )
def inActive_onDialogProceeding( self, event ):
dialog = [ d for d in self.dialogs.itervalues() ][0]
transaction = dialog.transaction
#FIXME:
e = transaction.lastRequestEvent
ne = createResponseEvent( e, 200 )
self.notify( ne, True )
event.handled = True
示例2: __init__
class TransitiveInheritanceDictionary:
##
# Initialize a transitive inheritance dictionary given an include dictionary.
##
def __init__(self, inheritanceDictionary):
# initialize an empty dictionary
self.dict = {}
self.inhDict = inheritanceDictionary
self.calculateTransitiveSuperclasses()
self.inhDict = None
self.log = Logger().get_instance(self)
##
# Add the transitive included files for each including file.
##
def calculateTransitiveSuperclasses(self):
for subclass in self.inhDict.dict:
transitiveSuperclasses = self.inhDict.getTransitiveSuperclasses(subclass)
self.dict[subclass] = transitiveSuperclasses
##
# Is the dictionary aware of any superclasses of the given className
##
def hasKey(self, className):
return className in self.dict
##
# Retrieve a list of names of transitive superclasses of the given class-name.
##
def getTransitiveSuperclasses(self, className):
superclasses = []
if className in self.dict:
superclasses = self.dict[className]
return superclasses
##
# Verify whether the given superclass-name is a known (transitive) superclass of the given subclass-name.
##
def isSubclassOf(self, subclassName, superclassName):
return superclassName in self.getTransitiveSuperclasses(subclassName)
##
# Print the contents of the dictionary.
##
def printContent(self):
self.log.info("Dictionary has", len(self.dict), "elements:")
for key in self.dict:
self.log.info("[", key, ",", self.getTransitiveSuperclasses(key), "]")
示例3: Resources
class Resources(Node):
"""Dispatches incoming MessageEvents based on the Request-URI."""
def __init__( self, name, parent ):
super( Resources, self ).__init__( name, parent )
self.log = Logger().get_instance( self.__class__.__name__ )
self.resources = {}
def identifyEvent( self, event ):
self.log.info( str(event) )
if isinstance( event, MessageEvent ):
return event.id
elif isinstance( event, ResourceEvent ):
return event.id
raise SipException( '[' + str(self.name) + '] ' + 'Ignoring event ' + str(event) + '.' )
def onBind( self, event ):
obj = importExtension( event.clsName )
if obj:
resource = obj( str(event.uri), self )
if resource:
resource.addListener( self )
self.resources[event.uri] = resource
if not obj or not resource:
raise Exception( 'Failed to import resource, ' + str(event.uri) + ', of type, ' + str(event.clsName) + '.' )
event.handled = True
def onUnbind( self, event ):
del self.resources[event.uri]
event.handled = True
def onRxRequest( self, event ):
try:
host = event.message.requestUri.host
resource = self.resources[host]
self.send( event, resource, queued=False )
except KeyError:
pass
def onRxResponse( self, event ):
raise 'FIXME:IMPLEMENT: Need to find the corresponding request, then the request-URI, then look up the resource in self.resources.'
def onTxRequest( self, event ):
self.notify( event, queued=False )
def onTxResponse( self, event ):
self.notify( event, queued=False )
示例4: Event
class Event(Loadable):
def __init__(self, eventName=None):
self.log = Logger().get_instance(self.__class__.__name__)
self.eventName = eventName
self.eventParameters = []
def setDict(self, dictData):
self.log.debug(str(dictData))
self.eventName = dictData["eventName"]
self.eventParameters = dictData["eventParameters"]
示例5: Parser
class Parser(object):
def __init__(self,fileName):
self.log = Logger().get_instance(self.__class__.__name__)
self.log.debug('Init parser for file '+fileName)
self.fileName = fileName
def loadInClass(self,className):
pass
示例6: Item
class Item(object):
'''
classdocs
'''
_name = ""
_gold = 0
_effects = []
_type = 'Item'
_magical = False
_ranged = True
_modfiers = []
_profil = []
_maxUsage = -1
def __init__(self, name=None, gold=0, effects=None):
'''
Constructor
'''
'''
Logger
'''
self.log = Logger().get_instance(self.__class__.__name__)
self._name = name
self._gold = gold
self._effects = effects
self._type = None
self._basePurchasePrice = 0
def equip(self, target):
pass
def unequip(self, target):
pass
def use(self, target):
pass
def setDict(self,dictData):
self.log.debug(str(dictData))
self._name = dictData['name']
self._type = dictData['type']
self._gold = dictData['gold']
self._basePurchasePrice = dictData['basePurchasePrice']
self._description = dictData['description']
if dictData.has_key('stock'):
self._ranged = dictData['stock']
if dictData.has_key('maxUsage'):
self._ranged = dictData['maxUsage']
if dictData.has_key('ranged'):
self._ranged = dictData['ranged']
示例7: AsciiRender
class AsciiRender(Render):
pass
def __init__(self):
self.log = Logger().get_instance(self.__class__.__name__)
def renderTabletop(self,tableTop):
asciiMap = ''
index=0
self.log.debug('Tabletop size x:'+str(tableTop.sizeX)+' y:'+str(tableTop.sizeY))
for i in range(0,tableTop.sizeY):
for j in range(0,tableTop.sizeX):
tile = tableTop.tiles[index]
asciiMap += self.getImageForTile(tile)
index +=1
asciiMap += '\n'
print asciiMap
def renderZone(self,zone):
asciiMap = ''
index=0
self.log.debug('Zone size x:'+str(zone.sizeX)+' y:'+str(zone.sizeY))
asciiMap += '\n| |'
for x in range(zone.getMinX(),zone.getMaxX() +1 ):
asciiMap += '|'+str(x)+'|'
asciiMap += '\n'
for y in range(zone.getMinY(),zone.getMaxY() +1 ):
asciiMap += '|'+str(y)+'|'
for x in range(0,zone.sizeX):
tile = zone.tiles[index]
asciiMap += self.getImageForTile(tile)
index +=1
asciiMap += '\n'
return asciiMap
def getImageForTile(self,tile):
if tile != None and tile.hasFunction('IO'):
return '[D]'
if tile != None and tile.hasFunction('Idol'):
return '[@]'
if tile != None and tile.hasFunction('Fire'):
return '[w]'
if tile != None and tile.hasFunction('Water'):
return '[~]'
if tile != None and tile.hasFunction('D'):
return '[ ]'
return '___';
示例8: __init__
class AccessDictionary:
# initialize an empty dictionary
dict = {}
##
# Initialize a dictionary.
##
def __init__(self):
self.log = Logger().get_instance(self)
pass
##
# Print the dictionary
##
def printContent(self):
self.log.info("Dictionary has", len(self.dict), "elements:")
for key in self.dict:
self.log.info( "[",key,",",self.convertToList(self.dict[key]),"]")
def createKey(self, fileName, lineNr):
return fileName+":"+lineNr
def hasKeyFor(self, fileName, lineNr):
return self.hasKey(self.createKey(fileName,lineNr))
def hasKey(self, key):
return self.dict.has_key(key)
def getValue(self, fileName, lineNr):
assert self.hasKey(self.createKey(fileName, lineNr))
return self.dict[self.createKey(fileName, lineNr)]
def getValueAsList(self, fileName, lineNr):
return self.getValue(fileName, lineNr).split(",")
def convertToList(self, value):
return value.split(",")
def add(self, fileName, lineNr, typeClass):
if typeClass != "" and typeClass != None:
key = self.createKey(fileName, lineNr)
value = typeClass
if self.dict.has_key(key) :
value = self.dict[key]
valueAsList=self.convertToList(value)
if not typeClass in valueAsList:
value=value+","+typeClass
self.dict[key] = value
示例9: __init__
class TileFunction:
def __init__(self):
self.log = Logger().get_instance(self.__class__.__name__)
self.name = ''
self.objectType = ''
self.code = ''
def setDict(self,dictData):
self.log.debug(str(dictData))
self.name = dictData['name']
self.objectType = dictData['objectType']
self.code = dictData['code']
示例10: __init__
class PackageDictionary:
##
# Initialize a dictionary.
##
def __init__(self):
self.dict={}
self.log = Logger().get_instance(self)
##
# Verify whether the dictionary contains a given Package-name.
##
def hasKey(self, nsName):
return (nsName in self.dict)
##
# Add a Package contained in the given sourceFile at the given line-nr
# to the dictionary.
#
# @nsName - the name of the Package
# @sourceFile - the name of the file in which the Package is declared
#
# @returns True/False indicating whether the Package was added
##
def add(self,sourceFile, nsName):
isAdded = False
if ( not(sourceFile in self.dict) ):
self.dict[sourceFile] = nsName
isAdded = True
else:
self.log.warn("Ignoring additional package declaration "+nsName+"for file ",\
sourceFile+" already packaged in "+self.dict[sourceFile])
return isAdded
##
# Retrieve a list of [sourceFile, lineNr] elements for which it holds
# that in sourceFile at lineNr a class with name className is declared.
#
# @param className - the class name for which to find source locations.
#
# @returns a list of elements [sourceFile, lineNr]
##
def getPackageForFile(self, sourceFile):
noNS = ""
if ( sourceFile in self.dict ):
return self.dict[sourceFile]
else:
return noNS
示例11: __init__
def __init__(self,pkgDict,impDict,inhDict, classDict,methDict,mtdSrcDict,miList, mtdpfDict, sFile,nr,content, raw):
self.log = Logger().get_instance(self)
self.pkgDict = pkgDict
self.impDict = impDict
self.inhDict = inhDict
self.classDict = classDict
self.methDict = methDict
self.mtdSrcDict = mtdSrcDict
self.miList = miList
self.sourceFile = sFile
self.lineNr = nr
self.content = content
self.raw = raw # full grep content
self.mtdpfDict = mtdpfDict
# to be filled in
self.src_unqName = None # fully qualified caller method
self.src_name = None # caller method
self.src_param = None # caller method parameters
self.dst_base = None
self.dst_name = None
self.dst_param = None
self.srcLoc = None # caller method filename
self.srcLineNr = None # caller method line number
self.dstLoc = None
self.dstLineNr = None
示例12: __init__
def __init__(self, line):
self.log = Logger().get_instance(self)
cols = line.split(":")
self.sourceFile = cols[0].replace("./", "")
self.lineNr = cols[1]
self.content = cols[2].lstrip().split(" ")[0].strip() # typically some code behind it
self.owner = ""
示例13: __init__
def __init__(self, mtdSrcDict, classDict, pkgDict, impDict, mtdInv):
self.mtdSrcDict = mtdSrcDict
self.classDict = classDict
self.pkgDict = pkgDict
self.impDict = impDict
self.mtdInv = mtdInv
self.log = Logger().get_instance(self)
示例14: __init__
def __init__(self, line):
line = line.strip()
self.metricLOC, self.metricCC, self.metricCOM, \
self.pkgName, self.className, self.methodName = \
self.__decomposeCols(line)
self.invEntRef = None # ref to invokable entity; to be resolved later
self.log = Logger().get_instance(self)
示例15: __init__
def __init__(self, activityDescription):
if sys.platform == "win32":
self.timer = time.clock
else:
self.timer = time.time
self.begin = self.end = 0
self.activityDescription = activityDescription
self.logger = Logger().get_instance(self)