From a0942bd8901723333f7ef8b8d0df26221e5d7156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Tue, 2 May 2006 11:49:53 +0000 Subject: [PATCH] * log important events --- pisi/api.py | 6 +++++- pisi/cli/__init__.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pisi/api.py b/pisi/api.py index 583488df..3e66b81a 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -16,6 +16,7 @@ import os import sys +import syslog from os.path import exists import bsddb3.db as db @@ -65,6 +66,7 @@ def init(database = True, write = True, else: ctx.ui = ui + syslog.openlog('pisi') # initialize log # If given define stdout and stderr. Needed by buildfarm currently # but others can benefit from this too. @@ -73,7 +75,6 @@ def init(database = True, write = True, if stderr: ctx.stderr = stderr - import pisi.config ctx.config = pisi.config.Config(options) @@ -103,6 +104,9 @@ def init(database = True, write = True, def finalize(): if ctx.initialized: + + syslog.closelog() + pisi.repodb.finalize() pisi.installdb.finalize() if ctx.filesdb != None: diff --git a/pisi/cli/__init__.py b/pisi/cli/__init__.py index 021547d4..aa974c6d 100644 --- a/pisi/cli/__init__.py +++ b/pisi/cli/__init__.py @@ -11,6 +11,7 @@ # import sys +import syslog import locale import gettext @@ -66,6 +67,7 @@ class CLI(UI): def info(self, msg, verbose = False, noln = False): # TODO: need to look at more kinds of info messages # let's cheat from KDE :) + #syslog.syslog(syslog.LOG_INFO, msg) if noln: msgend = '' else: @@ -74,6 +76,7 @@ class CLI(UI): def warning(self, msg, verbose = False): msg = unicode(msg) + syslog.syslog(syslog.LOG_WARNING, msg) if ctx.get_option('no_color'): self.output(_('Warning: ') + msg + '\n', err=True, verbose=verbose) else: @@ -81,6 +84,7 @@ class CLI(UI): def error(self, msg): msg = unicode(msg) + syslog.syslog(syslog.LOG_ERROR, msg) if ctx.get_option('no_color'): self.output(_('Error: ') + msg + '\n', err=True) else: @@ -89,6 +93,7 @@ class CLI(UI): def action(self, msg, verbose = False): #TODO: this seems quite redundant? msg = unicode(msg) + syslog.syslog(syslog.LOG_INFO, msg) self.output(colorize(msg + '\n', 'green')) def choose(self, msg, opts): @@ -147,3 +152,4 @@ class CLI(UI): msg = None if msg: self.output(colorize(msg + '\n', 'cyan')) + syslog.syslog(syslog.LOG_NOTICE, msg)