simplified logging. creates logging stuff in linspector now. no Logger class needed anymore. more advanced output in log message like filename,funcname,linenumber

This commit is contained in:
Johannes Findeisen 2013-09-25 03:08:24 +02:00
commit 4048bc252e
4 changed files with 51 additions and 22 deletions

View file

@ -71,7 +71,7 @@ class ConfigParser:
with open(configFilename) as cfgFile:
config = cfgFile.read()
self.log.i("reading Config: " + configFilename)
self.log.info("reading Config: " + configFilename)
return json.loads(config)
def _create_raw_Object(self, jsonDict, msgName, creator):
@ -90,8 +90,8 @@ class ConfigParser:
item = creator(key, val)
items.append(item)
except Exception:
self.log.w("ignoring " + msgName + ": " + key + "! reason:")
self.log.w(str(Exception))
self.log.warning("ignoring " + msgName + ": " + key + "! reason:")
self.log.warning(str(Exception))
return items
def _load_module(self, clazz, modPart):
@ -135,15 +135,15 @@ class ConfigParser:
if class_check(item):
repl.append(item)
else:
self.log.w("Ignoring class " + clazzItem["class"] + "! It does not pass the class check!")
self.log.warning("Ignoring class " + clazzItem["class"] + "! It does not pass the class check!")
except ImportError, err:
self.log.w("Could not import " + clazz + ": " + str(clazzItem) + "! reason")
self.log.w(str(err))
self.log.warning("Could not import " + clazz + ": " + str(clazzItem) + "! reason")
self.log.warning(str(err))
except KeyError, k:
self.log.w("Key " + str(k) + " not in classItem " + str(clazzItem))
self.log.warning("Key " + str(k) + " not in classItem " + str(clazzItem))
except Exception, e:
self.log.w("Error while replacing class ( " + clazz + " ): " + str(e))
self.log.warning("Error while replacing class ( " + clazz + " ): " + str(e))
del items[:]
items.extend(repl)

View file

@ -27,12 +27,12 @@ class Command:
try:
self.commandStart = dt.now()
self.log.i("calling command " + str(self.command) + " at " + str(self.commandStart))
self.log.info("calling command " + str(self.command) + " at " + str(self.commandStart))
#self.output=sp.check_output(self.command.split())
process = Popen(self.command, stdout=sp.PIPE, stderr=sp.PIPE, shell=True)
self.output, self.error = process.communicate()
self.log.d(str(self.output))
self.log.d(str(self.error))
self.log.debug(str(self.output))
self.log.debug(str(self.error))
self.retcode = process.poll()
except CalledProcessError:
self.error = CalledProcessError.output

View file

@ -40,7 +40,7 @@ class Job:
self.jobThreshold += 1
if self.jobThreshold >= serviceThreshold:
self.log.d("Threshold reached!")
self.log.debug("Threshold reached!")
self.handle_alarm(jobInfo, self.jobThreshold - serviceThreshold)
def handle_alarm(self, jobInfo, thresholdOffset):
@ -49,8 +49,8 @@ class Job:
task.execute(jobInfo.get_message(), self.core)
def handle_call(self):
self.log.d("handle call")
self.log.d(self.service)
self.log.debug("handle call")
self.log.debug(self.service)
try:
jobInfo = JobInfo(self.host, self.service)
self.service._execute(jobInfo)
@ -58,12 +58,12 @@ class Job:
self.handle_threshold(jobInfo, self.service.get_threshold(), jobInfo.was_execution_successful())
self.log.d("Code: " + str(jobInfo.get_errorcode()) + ", Message: " + str(jobInfo.get_message()))
self.log.debug("Code: " + str(jobInfo.get_errorcode()) + ", Message: " + str(jobInfo.get_message()))
self.jobInfos.append(jobInfo)
except Exception, e:
self.log.d(e)
self.log.debug(e)
class JobInfo(object):