* log important events

This commit is contained in:
Eray Özkural
2006-05-02 11:49:53 +00:00
parent a83cea09d6
commit a0942bd890
2 changed files with 11 additions and 1 deletions
+5 -1
View File
@@ -16,6 +16,7 @@
import os import os
import sys import sys
import syslog
from os.path import exists from os.path import exists
import bsddb3.db as db import bsddb3.db as db
@@ -65,6 +66,7 @@ def init(database = True, write = True,
else: else:
ctx.ui = ui ctx.ui = ui
syslog.openlog('pisi') # initialize log
# If given define stdout and stderr. Needed by buildfarm currently # If given define stdout and stderr. Needed by buildfarm currently
# but others can benefit from this too. # but others can benefit from this too.
@@ -73,7 +75,6 @@ def init(database = True, write = True,
if stderr: if stderr:
ctx.stderr = stderr ctx.stderr = stderr
import pisi.config import pisi.config
ctx.config = pisi.config.Config(options) ctx.config = pisi.config.Config(options)
@@ -103,6 +104,9 @@ def init(database = True, write = True,
def finalize(): def finalize():
if ctx.initialized: if ctx.initialized:
syslog.closelog()
pisi.repodb.finalize() pisi.repodb.finalize()
pisi.installdb.finalize() pisi.installdb.finalize()
if ctx.filesdb != None: if ctx.filesdb != None:
+6
View File
@@ -11,6 +11,7 @@
# #
import sys import sys
import syslog
import locale import locale
import gettext import gettext
@@ -66,6 +67,7 @@ class CLI(UI):
def info(self, msg, verbose = False, noln = False): def info(self, msg, verbose = False, noln = False):
# TODO: need to look at more kinds of info messages # TODO: need to look at more kinds of info messages
# let's cheat from KDE :) # let's cheat from KDE :)
#syslog.syslog(syslog.LOG_INFO, msg)
if noln: if noln:
msgend = '' msgend = ''
else: else:
@@ -74,6 +76,7 @@ class CLI(UI):
def warning(self, msg, verbose = False): def warning(self, msg, verbose = False):
msg = unicode(msg) msg = unicode(msg)
syslog.syslog(syslog.LOG_WARNING, msg)
if ctx.get_option('no_color'): if ctx.get_option('no_color'):
self.output(_('Warning: ') + msg + '\n', err=True, verbose=verbose) self.output(_('Warning: ') + msg + '\n', err=True, verbose=verbose)
else: else:
@@ -81,6 +84,7 @@ class CLI(UI):
def error(self, msg): def error(self, msg):
msg = unicode(msg) msg = unicode(msg)
syslog.syslog(syslog.LOG_ERROR, msg)
if ctx.get_option('no_color'): if ctx.get_option('no_color'):
self.output(_('Error: ') + msg + '\n', err=True) self.output(_('Error: ') + msg + '\n', err=True)
else: else:
@@ -89,6 +93,7 @@ class CLI(UI):
def action(self, msg, verbose = False): def action(self, msg, verbose = False):
#TODO: this seems quite redundant? #TODO: this seems quite redundant?
msg = unicode(msg) msg = unicode(msg)
syslog.syslog(syslog.LOG_INFO, msg)
self.output(colorize(msg + '\n', 'green')) self.output(colorize(msg + '\n', 'green'))
def choose(self, msg, opts): def choose(self, msg, opts):
@@ -147,3 +152,4 @@ class CLI(UI):
msg = None msg = None
if msg: if msg:
self.output(colorize(msg + '\n', 'cyan')) self.output(colorize(msg + '\n', 'cyan'))
syslog.syslog(syslog.LOG_NOTICE, msg)