本文整理汇总了Python中log4py.Logger.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.debug方法的具体用法?Python Logger.debug怎么用?Python Logger.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log4py.Logger
的用法示例。
在下文中一共展示了Logger.debug方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
class ResolutionReport:
##
# Initialize the generic data.
##
def __init__(self, line):
self.line = line.strip()
self.entityType = "Undefined"
self.logger = Logger().get_instance(self)
self.logger.set_loglevel(LOGLEVEL_DEBUG)
##
# Return a string representation of the report.
##
def __repr__(self):
assert False, "Should be implemented by subclass."
##
# Verify whether the resolution succeeded.
##
def resolutionSucceeded(self):
assert False, "Should be implemented by subclass."
def log(self):
self.logger.debug("Failed to resolve " + self.entityType + ": " + self.line)
self.logger.debug(self.__repr__())
def logIfFlawed(self):
if self.resolutionFeasible() and (not self.resolutionSucceeded()):
self.log()
示例2: Event
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
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"]
示例3: Parser
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
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
示例4: Item
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
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']
示例5: AsciiRender
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
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 '___';
示例6: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
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']
示例7: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
class ZoneDealer:
def __init__(self,zones = []):
self.log = Logger().get_instance(self.__class__.__name__)
self.zones = zones
def addZone(self,zone):
self.log.debug('Add zone '+zone.name)
self.zones.append(zone)
def getAndRemoveZone(self):
if len(self.zones) > 0:
zone = self.zones.pop()
zone.zoneDealer = self
return zone
def split(self,count):
split = {}
if count == 0:
return None
elif count == 1:
split[0] = self
else:
for i in range(0,count):
split[i] = []
index = 0
for zone in self.zones:
split[index].append(zone)
index = index + 1
if index == count:
index=0
for i in range(0,count):
split[i] = ZoneDealer(split[i])
return split
def __str__(self, *args, **kwargs):
data = 'There are '+str(len(self.zones))+' zone in zoneDealer'
return data
示例8: Tile
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
class Tile(object):
def __init__(self):
self.log = Logger().get_instance(self.__class__.__name__)
self.zone = None
self.functions = []
self.contiguous = {}
self.contiguous['south'] = None
self.contiguous['north'] = None
self.contiguous['east'] = None
self.contiguous['west'] = None
self.character = None
def placeCharacter(self,character):
EventService.fireEvent('onTileEnter',{'tile':self,'character':character})
self.character = character
def removeCharacter(self):
character = self.character
self.character = None
EventService.fireEvent('onTileExit',{'tile':self,'character':character})
def hasCharacter(self):
return self.character != None
def addFunction(self,function):
self.functions.append(function)
def setFunctions(self,functions):
self.functions = functions
self.log.debug(str(self.functions))
def hasFunction(self,code):
for function in self.functions:
if function.code == code:
return True
return False
def hasNeighbor(self,direction):
return self.contiguous[direction] != None
def countNeighbor(self):
direction = ''
count = 0
if self.contiguous['south'] != None:
direction = direction + 'S'
count = count + 1
else:
direction = direction + ' '
if self.contiguous['north'] != None:
direction = direction + 'N'
count = count + 1
else:
direction = direction + ' '
if self.contiguous['east'] != None:
direction = direction + 'E'
count = count + 1
else:
direction = direction + ' '
if self.contiguous['west'] != None:
direction = direction + 'W'
count = count + 1
else:
direction = direction + ' '
self.log.debug('['+direction+']')
return count
def addTileNeighborAt(self,tile,direction):
if self == tile:
raise Exception('Stop, i can''t be my Neighbor')
compatibleDirection = Direction.directionCompatibility[direction]
if not (self.hasFunction('B') or tile.hasFunction('B')) :
self.contiguous[direction]=tile
tile.contiguous[compatibleDirection]=self
示例9: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
class LoggingProducerUtils:
def __init__(self,parameterContainer, logLevel=log4py.LOGLEVEL_DEBUG, logTarget=LOGGER_PRODUCER_LOG_DIR):
if parameterContainer.getParamValue(PRINTER_TYPE) is not None:
self.__errorFileName = "%s" % (parameterContainer.getErrorFileName())
self.__logFileName = "%s/%s-%s.log" % (parameterContainer.getParamValue(TMP_DIR),parameterContainer.getParamValue(PRINTER_TYPE), parameterContainer.getParamValue(PRINTER_NAME))
else:
if parameterContainer.getParamValue(PARAM_DIR) is not None:
if os.access(parameterContainer.getFullPathJobDir(), os.W_OK) :
# Error/Log directory locally
self.__errorFileName = "%s/%s" % (parameterContainer.getFullPathJobDir(), parameterContainer.getErrorFileName())
self.__logFileName = "%s/%s.log" % (parameterContainer.getFullPathJobDir(), parameterContainer.getJobID())
else:
# Error/Log directory remotely
self.__errorFileName = "%s/%s" % (parameterContainer.getInputDir(), parameterContainer.getErrorFileName())
self.__logFileName = "%s/%s.log" % (parameterContainer.getInputDir(), parameterContainer.getJobID())
else:
self.__errorFileName = "%s/%s" % (LOG_DIRECTORY, parameterContainer.getErrorFileName())
self.__logFileName = "%s/%s.log" % (LOG_DIRECTORY, parameterContainer.getJobID())
### LOG4PY ###
self._log4py = Logger().get_instance(self)
self._jobid = parameterContainer.getJobID()
# Set target(s) according to configuration
if logTarget == LOGGER_JOBS_DIR and self.__logFileName is not None:
self.__log4pyFile = self.__logFileName
else:
# Log to the producer log directory using the OsEnv variable from producerjavastarter.py
#self.__log4pyFile = '/prod_data/sefas/data/traffic/log/producer_log4py_' + self.getLogFileTimestamp() +'.log'
self.__log4pyFile = LOG_DIRECTORY+'/producer_log4py_' + self.getLogFileTimestamp() +'.log'
self._log4py.set_target(self.__log4pyFile)
# Set time format
timeformat = "%Y-%m-%d %H:%M:%S "
self._log4py.set_time_format(timeformat)
# Set log format
self._log4py.set_formatstring(FMT_SEFAS)
# Set level from configuration file?
self._log4py.set_loglevel(logLevel)
# Set rotation
self._log4py.set_rotation(log4py.ROTATE_DAILY)
### END LOG4PY ###
def getLogFileTimestamp(self):
t = datetime.datetime.now();
return t.strftime("%Y%m%d")
# Wrap the log4py methods
def info(self, msg):
if self._jobid is not None:
self._log4py.info("[JOB_ID=" + self._jobid + "] %s" % msg)
else:
self._log4py.info("[NO JOB_ID] %s" % msg)
def error(self, msg, exceptionType=None, exceptionValue=None):
self._log4py.set_target(self.__errorFileName)
if self._jobid is not None:
self._log4py.error("[JOB_ID=" + self._jobid + "] %s" % msg)
else:
self._log4py.error("[NO JOB_ID] %s" % msg)
if exceptionType != None and exceptionValue != None:
type, values, tb = sys.exc_info()
traceback.print_exception(exceptionType, exceptionValue, tb)
if self._jobid is not None:
self._log4py.error("[JOB_ID=" + self._jobid + "] %s" % tb)
else:
self._log4py.error("[NO JOB_ID] %s" % tb)
# Finally write to regular log
self._log4py.set_target(self.__log4pyFile)
self._log4py.error(msg)
def debug(self, msg):
if self._jobid is not None:
self._log4py.debug("[JOB_ID=" + self._jobid + "] %s" % msg)
else:
self._log4py.debug("[NO JOB_ID] %s" % msg)
def warn(self, msg):
if self._jobid is not None:
self._log4py.warn("[JOB_ID=" + self._jobid + "] %s" % msg)
else:
self._log4py.warn("[NO JOB_ID=] %s" % msg)
def getFormatString(self):
self._log4py.get_formatstring()
def setFormatString(self, format):
self._log4py.set_formatstring(format)
# Wrap the loglevel and target
def setLogLevel(self, level):
self._log4py.set_loglevel(level)
def setLogTarget(self, target):
self._log4py.set_target(target)
#.........这里部分代码省略.........
示例10: Engine
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
class Engine(object):
def __init__(self):
self.log = Logger().get_instance(self.__class__.__name__)
self.loaders = []
self.data = {}
self.donjonSubTypeCount = {}
self.generateDongeonArray = []
self.renderObject = None
self.tableTop = TableTop()
self.firstZoneDealer = None
def load(self):
for loader in self.loaders:
loader.load(self.data)
self.log.info(loader.__class__.__name__ + " Finished")
print "Run loaders Finished"
def authorizeDungeonSubTypeCount(self, subType, count):
if subType in self.data["zone"]:
self.donjonSubTypeCount[subType] = count
def addLoader(self, loader):
self.loaders.append(loader)
def setRender(self, render):
self.renderObject = render
def render(self):
# =======================================================================
# self.tableTop.addZone(self.generateDongeonArray[0])
# self.renderObject.renderTabletop(self.tableTop)
# self.tableTop.addZone(self.generateDongeonArray[1])
# self.renderObject.renderTabletop(self.tableTop)
# self.tableTop.addZone(self.generateDongeonArray[2])
# self.renderObject.renderTabletop(self.tableTop)
# self.tableTop.addZone(self.generateDongeonArray[3])
# self.renderObject.renderTabletop(self.tableTop)
# self.tableTop.addZone(self.generateDongeonArray[4])
# =======================================================================
self.log.debug(str(self.firstZoneDealer))
self.tableTop.initialConnector.zoneDealer = self.firstZoneDealer
self.tableTop.addZone(self.tableTop.initialConnector, self.firstZoneDealer)
self.renderObject.renderTabletop(self.tableTop)
def generateDongeon(self):
zoneDealer = ZoneDealer()
generateDongeonArray = []
for objectType, value in self.donjonSubTypeCount.iteritems():
for i in range(0, value):
generateDongeonArray.append(self.takeOneRandomZoneOfType(objectType, value - i))
random.shuffle(generateDongeonArray)
self.pushObjectiveZoneToDeep(generateDongeonArray)
for zone in generateDongeonArray:
zoneDealer.addZone(zone)
self.firstZoneDealer = zoneDealer
def takeOneRandomZoneOfType(self, subType, countAgain):
tempArray = self.data["zone"][subType]
self.log.debug("data for " + subType + ":" + str(tempArray))
if not self.hasNonUniqueZone(tempArray):
if len(tempArray) < countAgain:
raise Exception(
"There are not enougth zone subtype "
+ subType
+ ". rest "
+ str(len(tempArray))
+ " needed "
+ str(countAgain)
)
random.shuffle(tempArray)
if tempArray[0].unique:
uniqueZone = tempArray[0]
tempArray.remove(uniqueZone)
return uniqueZone
else:
return copy.deepcopy(tempArray[0])
def pushObjectiveZoneToDeep(self, generateDongeon):
for zone in generateDongeon:
if zone.subType == "objective-zone":
generateDongeon.remove(zone)
countItems = len(generateDongeon)
afterLimit = countItems / 3 # * 2
self.log.debug("push objective zone after " + str(afterLimit) + " index")
randomIndex = random.randrange(afterLimit, countItems)
self.log.debug("push objective zone in " + str(randomIndex) + " index")
generateDongeon.insert(randomIndex, zone)
break
#.........这里部分代码省略.........
示例11: TableTop
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
class TableTop(Grid):
def __init__(self):
self.log = Logger().get_instance(self.__class__.__name__)
super(TableTop,self).__init__()
self.zones = []
self.lastZones = []
self.sizeY = 0
self.sizeX = 2
self.initialConnector = Connector(None)
self.initialConnector.position1X = 0
self.initialConnector.position1Y = -1
self.initialConnector.position2X = 1
self.initialConnector.position2Y = -1
self.initialConnector.direction = 'south'
self.initialConnector.zoneDealer = None
def addZone(self,connector,zoneDealer):
if zoneDealer == None:
return False
zone = zoneDealer.getAndRemoveZone()
if zone == None:
return False
self.log.debug('Add zone '+zone.name)
#convert to PostionnedZone
zone = PositionnedZone(zone)
self.log.debug('nb tiles '+str(len(zone.tiles)))
self.connectNewZone(connector,zone)
if zone.subType == 'objective-zone':
return False
return True
def connectNewZone(self,connector,zone):
#=======================================================================
# #has last zone
# if len(self.lastZones) == 0:
# self.log.debug(zone.name + ' is the first zone ')
#
# else:
# lastZone = self.lastZones[-1]
# self.log.debug('connect new '+zone.name )
# if not lastZone.hasFreeConnector():
# raise ZoneConnectorException('old zone has no free connector')
# self.log.debug(' to last '+lastZone.name)
# if not zone.hasFreeConnector():
# raise ZoneConnectorException('new zone has no free connector')
# self.log.debug('check last connector '+lastZone.name)
# if len(lastZone.getFreeConnectors()) > 1:
# self.log.debug('more than one free connector to connect')
# connectTo = lastZone.getOneFreeConnector()
# else:
# connectTo = lastZone.getOneFreeConnector()
#
# if not zone.rotateForCompatibleConnector(connectTo):
# raise ZoneConnectorException('No connector available')
#
#
#=======================================================================
#self.lastZones.append(zone)
self.resizeTableTopAndAddTiles(connector,zone)
for connector in zone.getFreeConnectors():
self.log.debug('Add zone '+str(connector))
self.addZone(connector, connector.zoneDealer)
def resizeTableTopAndAddTiles(self,connectTo,zone):
self.log.debug('Direction '+connectTo.direction+', resize, old size '+str(self.sizeX)+'x'+str(self.sizeY)+' with '+str(len(self.tiles))+' tiles')
self.log.debug('A -- zone have '+str(len(zone.tiles))+' tiles')
self.log.debug('connectTo:'+str(connectTo))
self.log.debug('zone:'+str(zone))
actualX = connectTo.position1X
actualY = connectTo.position1Y
self.log.debug('actualX:'+str(actualX))
self.log.debug('actualY:'+str(actualY))
compatibleConnector = zone.getCompatibleConnector(connectTo)
self.log.debug('connect to compatible:'+str(compatibleConnector))
compatibleConnectorX = compatibleConnector.position1X
compatibleConnectorY = compatibleConnector.position1Y
translateX = actualX - compatibleConnectorX
translateY = actualY - compatibleConnectorY
self.log.debug('translateX:'+str(translateX))
#.........这里部分代码省略.........
示例12: Zone
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import debug [as 别名]
class Zone(Grid):
def __init__(self,tileFunctionLoader):
'''
Logger
'''
self.log = Logger().get_instance(self.__class__.__name__)
'''
Init super
'''
super(Zone,self).__init__()
'''
Tile loader able to convert tile CODE
'''
self.tileFunctionLoader = tileFunctionLoader
'''
Name of zone
'''
self.name = ''
'''
Type of this zone, type is define in data filename <type>.<class>.<parser>
'''
self.objectType = ''
'''
Subtype of this zone
'''
self.subType = None
'''
Is this zone can be duplicate in dungeon
'''
self.unique = False
'''
List of connectors for this zone
'''
self.connectors = {}
self.zoneDealer = None
def connectTile(self):
for y in range(0,self.sizeY-1):
for x in range(0,self.sizeX-1):
self.getTile(x,y).addTileNeighborAt(self.getTile(x+1, y),'east')
self.getTile(x,y).addTileNeighborAt(self.getTile(x, y+1),'south')
self.getTile(self.sizeX-1,y).addTileNeighborAt(self.getTile(self.sizeX-1, y+1),'south')
for x in range(0,self.sizeX-1):
self.getTile(x,self.sizeY-1).addTileNeighborAt(self.getTile(x+1, self.sizeY-1),'east')
##self.checkTileConnection()
def checkTileConnection(self):
self.log.debug('check tile for '+self.name+'('+str(self.sizeX)+','+str(self.sizeY)+')')
checkTile = {}
checkTile[0] = 0
checkTile[1] = 0
checkTile[2] = 0
checkTile[3] = 0
checkTile[4] = 0
for tile in self.tiles:
count = tile.countNeighbor()
checkTile[count] = checkTile[count] +1
corner = 4
border = (self.sizeX * 2) + ((self.sizeY - 2) * 2) - corner
center = (self.sizeX * self.sizeY) - border - corner
if checkTile[0] != 0:
raise Exception('Some tiles has not connected')
if checkTile[1] != 0:
raise Exception('Some tiles has not correctly connected')
if checkTile[2] != corner:
raise Exception('Corner are not correctly connected')
if checkTile[3] != border :
raise Exception('Border are not correctly connected '+ str(checkTile[3]) +' instead of '+ str(border))
if checkTile[4] != center:
raise Exception('Center are not correctly connected'+ str(checkTile[4]) +' instead of '+ str(center))
def addTile(self,tileDefinition):
newTile = Tile()
newTile.zone = self
newTile.setFunctions(self.tileFunctionLoader.getTileFunctionFromDefinition(tileDefinition))
self.tiles.append(newTile)
self.log.debug(self.name +' have ' +str(len(self.tiles))+ ' tiles')
def addLine(self,lineDefinition):
self.log.debug('tiles definition elements for '+self.name+' : ' + str(len(lineDefinition)))
for tileDefinition in lineDefinition:
self.addTile(tileDefinition)
if self.sizeY == None:
self.sizeX += 1
#.........这里部分代码省略.........