From: Michael Tremer Date: Tue, 11 May 2010 12:54:08 +0000 (+0200) Subject: naoki: Fix logging again. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dda8657f4bd7c2198b70a8d008f337d5d0643a4c;p=ipfire-3.x.git naoki: Fix logging again. --- diff --git a/naoki/backend.py b/naoki/backend.py index efc8c379a..73eccc53a 100644 --- a/naoki/backend.py +++ b/naoki/backend.py @@ -456,14 +456,18 @@ class Package(object): self.log.debug("Extracting %s..." % files) util.do("%s --root=%s %s" % (os.path.join(TOOLSDIR, "decompressor"), - dest, " ".join(files)), shell=True) + dest, " ".join(files)), shell=True, logger=self.log) def getEnvironment(self, *args, **kwargs): return chroot.PackageEnvironment(self, *args, **kwargs) + @property + def logfile(self): + return os.path.join(LOGDIR, self.repo.name, self.info.id) + ".log" + @property def log(self): - return self.naoki.logging.getBuildLogger(os.path.join(self.repo.name, self.info.id)) + return self.naoki.logging.getBuildLogger(self) def get_repositories(toolchain=False): @@ -632,21 +636,21 @@ Sincerely, # Read log and append it to mail logfile = os.path.join(LOGDIR, package.id + ".log") if os.path.exists(logfile): - log = [] + loglines = [] f = open(logfile) line = f.readline() while line: line = line.rstrip("\n") if line.endswith(LOG_MARKER): # Reset log - log = [] + loglines = [] - log.append(line) + loglines.append(line) line = f.readline() f.close() - log = email.mime.text.MIMEText("\n".join(log), _subtype="plain") + log = email.mime.text.MIMEText("\n".join(loglines), _subtype="plain") log.add_header('Content-Disposition', 'attachment', filename="%s.log" % package.id) msg.attach(log) diff --git a/naoki/logger.py b/naoki/logger.py index faff1d5b6..5ecf0ce47 100644 --- a/naoki/logger.py +++ b/naoki/logger.py @@ -59,12 +59,12 @@ class Logging(object): self.log.debug("Disabled debug logging mode") self.log.handlers[0].setLevel(logging.INFO) - def _setupBuildLogger(self, logger): + def _setupBuildLogger(self, logger, package): logger.setLevel(logging.DEBUG) logger.parent = self.log logger.propagate = 1 - logfile = os.path.join(LOGDIR, logger.name + ".log") + logfile = package.logfile logdir = os.path.dirname(logfile) if not os.path.exists(logdir): @@ -78,10 +78,10 @@ class Logging(object): logger.addHandler(handler) - def getBuildLogger(self, name): - logger = logging.getLogger(name) + def getBuildLogger(self, package): + logger = logging.getLogger(package.id) if not logger.handlers: - self._setupBuildLogger(logger) + self._setupBuildLogger(logger, package) return logger