From e3759d2a2e5fdb0e0a7f7dfa4f8244fdbb3ffe92 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Wed, 25 Jan 2006 16:48:06 +0000 Subject: Introduce the new logging infrastructure and convert the server (and bcfg2-info) over to using it git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1717 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Statistics.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/lib/Server/Statistics.py') diff --git a/src/lib/Server/Statistics.py b/src/lib/Server/Statistics.py index 15f1586ef..4a86cdf35 100644 --- a/src/lib/Server/Statistics.py +++ b/src/lib/Server/Statistics.py @@ -2,9 +2,10 @@ __revision__ = '$Revision$' from lxml.etree import XML, SubElement, Element, XMLSyntaxError -from syslog import syslog, LOG_ERR from time import asctime, localtime, time +import logging + class Statistics(object): '''Manages the memory and file copy of statistics collected about client runs''' __min_write_delay__ = 30 @@ -15,6 +16,7 @@ class Statistics(object): self.dirty = 0 self.lastwrite = 0 self.ReadFromFile() + self.logger = logging.getLogger('Bcfg2.Server.Statistics') def pretty_print(self, element, level=0): '''Produce a pretty-printed text representation of element''' @@ -53,12 +55,11 @@ class Statistics(object): self.dirty = 0 #syslog(LOG_INFO, "Statistics: Read in statistics.xml") except (IOError, XMLSyntaxError): - syslog(LOG_ERR, "Statistics: Failed to parse %s"%(self.filename)) + self.logger.error("Failed to parse %s"%(self.filename)) self.element = Element('ConfigStatistics') self.WriteBack() self.dirty = 0 - def updateStats(self, xml, client): '''Updates the statistics of a current node with new data''' @@ -91,7 +92,7 @@ class Statistics(object): node.remove(elem) else: # Shouldn't be reached - syslog(LOG_ERR, "Statistics: Duplicate node entry for %s"%(client)) + self.logger.error("Duplicate node entry for %s"%(client)) # Set current time for stats newstat.set('time', asctime(localtime())) -- cgit v1.2.3-1-g7c22