本文整理汇总了Python中log4py.Logger.error方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.error方法的具体用法?Python Logger.error怎么用?Python Logger.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log4py.Logger
的用法示例。
在下文中一共展示了Logger.error方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: returnSourceLocation
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import error [as 别名]
def returnSourceLocation(sourceIndication):
# Sample Entry:
# Constant 000023.007 spreadsheet/constant.h;23.15 0x0 {} {} {} {}
sourceIndicationParts = sourceIndication.split(";")
sourceFile=""
start = ""
if len(sourceIndicationParts) >= 2:
sourceFile = sourceIndicationParts[0]
sourceIndicationParts=sourceIndicationParts[1].split(".")
if len(sourceIndicationParts) >= 1:
start = sourceIndicationParts[0]
else:
log=Logger().get_instance()
log.error("Invalid sourceIndication(start): \"",sourceIndication,"\"")
else:
log=Logger().get_instance()
log.error("Invalid sourceIndication(sourceFile): \"",sourceIndication,"\"")
end = start # sadly, not end value in SN Db
return sourceFile, start, end
示例2: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import error [as 别名]
class IncludeDictionary:
##
# Initialize a dictionary.
##
def __init__(self):
# initialize an empty dictionary
self.dict = {}
self.log = Logger().get_instance(self)
##
# Does filename include other files?
##
def hasKey(self, fileName):
normalizedFileName=normalizeFileName(fileName)
return (normalizedFileName in self.dict )
##
# Retrieve a list of files included directly by the given file
##
def getIncludedFiles(self, includingFile):
includedFiles = []
normalizedIncludingFile=normalizeFileName(includingFile)
if ( normalizedIncludingFile in self.dict ):
includedFiles = self.dict[normalizedIncludingFile]
return includedFiles
##
# Retrieve a list of files included directly and indirectly by the given file.
##
def getTransitiveIncludedFiles(self, includingFile):
includedFiles = []
normalizedIncludingFile=normalizeFileName(includingFile)
self.getTransitiveIncludedFilesInternal(normalizedIncludingFile, includedFiles)
return includedFiles
def getTransitiveIncludedFilesInternal(self, includingFile, resultSet):
additionalResultSet = []
if self.hasKey(includingFile):
for includedFile in self.getIncludedFiles(includingFile):
if not ((includedFile in resultSet) or (includedFile in additionalResultSet)):
resultSet.append(includedFile)
additionalResultSet.append(includedFile)
for includedFile in additionalResultSet:
self.getTransitiveIncludedFilesInternal(includedFile, resultSet)
def addEntity(self, includeEntity):
return self.add(includeEntity.getIncludingFile(), \
includeEntity.getIncludedFile())
##
# Appends includedFile to the list of files included by includingFile.
#
# @returns True/False indicating whether the includedFile was added
##
def add(self, includingFile, includedFile):
if ( includingFile == None ) or ( includedFile == None ):
self.log.error("Preconditions violated: ",[includingFile,includedFile])
return False
added = False
normalizedIncludingFile=normalizeFileName(includingFile)
adjustedIncludedFile=adjustPath(normalizedIncludingFile,includedFile)
if not(normalizedIncludingFile in self.dict) :
self.dict[normalizedIncludingFile]=[]
if not (adjustedIncludedFile in self.dict[normalizedIncludingFile]):
self.dict[normalizedIncludingFile].append(adjustedIncludedFile)
added = True
return added
##
# 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.getIncludedFiles(key),"]")
示例3: AnAccessibleEntity
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import error [as 别名]
class AnAccessibleEntity(TypedEntity):
def __init__(self, line):
TypedEntity.__init__(self, line)
self.log = Logger().get_instance(self)
self.namespaceName = None
self.cols = self.line.split(";")
self.sourceIndicationIndex = -1 # to be initialized by subclass
self.visibilityIndicationIndex = -1 # to be initialized by subclass
self.nameIndex = -1 # to be initialized by subclass
self.initialize()
self.postInitialize() # for subclasses to override
def initialize(self):
self.initializeColsIndices()
if self.cols != ['']:
self.decomposeData()
##
# Initialize at least the following attributes:
# self.sourceIndicationIndex
# self.visibilityIndicationIndex
# self.nameIndex
##
def initializeColsIndices(self): abstract
##
# Provides an opportunity for subclasses to implement additional
# initializations. E.g., initialization of additional attirbutes.
##
def postInitialize(self):
pass
##
# Decomposes the entity line.
#
# @requires: self.cols to be initialized
# @ensures: class, name and type of both source and destination to be initialized
##
def decomposeData(self):
self.sourceFile = self.cols[self.sourceIndicationIndex]
self.start = self.cols[self.sourceIndicationIndex+1].split(".")[0]
self.end = self.start
#self.sourceFile, self.start, self.end = returnSourceLocation(self.cols[self.sourceIndicationIndex])
self.owner = ""
declaredType = self.retrieveDeclaredType()
typeReference = self.getTypeReference()
typeReference.setReferencedName(declaredType)
self.name = self.cols[self.nameIndex]
self.decomposeVisibilityData()
def retrieveDeclaredType(self):
dbfields=self.cols[self.visibilityIndicationIndex+1:]
contents = appendStringList(dbfields)
if ( contents[0] != "{" ):
self.log.error("Cannot deduce declared type from line.")
return
i = 1
attrChars = []
while contents[i] != "}":
attrChars.append(contents[i])
i = i + 1
return self.cleanType(''.join(attrChars))
def decomposeVisibilityData(self):
vis = self.cols[self.visibilityIndicationIndex]
if vis == "0x1":
self.visibility = "private"
self.hasClassScope = False
elif vis == "0x2":
self.visibility = "protected"
self.hasClassScope = False
elif vis == "0x4":
self.visibility = "public"
self.hasClassScope = False
elif vis == "0x9":
self.visibility = "private"
self.hasClassScope = True
elif vis == "0xa":
self.visibility = "protected"
self.hasClassScope = True
elif vis == "0xc":
self.visibility = "public"
self.hasClassScope = True
elif vis == "0x0": # constant global variables
self.visibility = "public"
self.hasClassScope = False
else:
typeReference = self.getTypeReference()
self.log.warn( "Unknown visibility indicator for entity ",\
typeReference.getReferencedName(),"::",self.name,": ",\
vis)
self.visibility = ""
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import error [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)
#.........这里部分代码省略.........