# Add settings from keyword arguments
self.settings.update(kwargs)
- # Setup logging
- self.setup_logging(logfile)
-
# Generate a build ID
self.build_id = build_id or "%s" % uuid.uuid4()
+ # Setup logging
+ self.log = self.setup_logging(logfile)
+
# Path
self.path = os.path.join(BUILD_ROOT, self.build_id)
self._destroy()
def setup_logging(self, logfile):
- if logfile:
- self.log = log.getChild(self.build_id)
- # Propage everything to the root logger that we will see something
- # on the terminal.
- self.log.propagate = 1
- self.log.setLevel(logging.INFO)
+ l = log.getChild(self.build_id)
+ l.setLevel(logging.DEBUG)
- # Add the given logfile to the logger.
+ # Print everything to the console
+ l.addHandler(
+ logging.StreamHandler(),
+ )
+
+ # If we have a log file, we write INFO and higher level messages to it
+ # using the build formatter which adds a timestamp
+ if logfile:
h = logging.FileHandler(logfile)
- self.log.addHandler(h)
+ h.setLevel(logging.INFO)
+ l.addHandler(h)
- # Format the log output for the file.
+ # Set formatter
f = logger.BuildFormatter()
h.setFormatter(f)
- else:
- # If no logile was given, we use the root logger.
- self.log = logging.getLogger("pakfire")
+
+ return l
def _make_cgroup(self):
"""
if not script:
continue
+ self.log.debug("Running stage '%s'" % stage)
+
# Run it
self.pakfire.execute_script(script,
enable_network=False, interactive=False)