* use a separate log file (/var/log/pisi.log) as onur asked

This commit is contained in:
Eray Özkural
2006-05-02 13:48:10 +00:00
parent f7ca28eb53
commit 630febca69
2 changed files with 12 additions and 9 deletions
+7 -3
View File
@@ -16,7 +16,7 @@
import os
import sys
import syslog
import logging
from os.path import exists
import bsddb3.db as db
@@ -66,7 +66,11 @@ def init(database = True, write = True,
else:
ctx.ui = ui
syslog.openlog('pisi') # initialize log
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S',
filename='/var/log/pisi.log',
filemode='w')
# If given define stdout and stderr. Needed by buildfarm currently
# but others can benefit from this too.
@@ -105,7 +109,7 @@ def init(database = True, write = True,
def finalize():
if ctx.initialized:
syslog.closelog()
logging.shutdown()
pisi.repodb.finalize()
pisi.installdb.finalize()
+5 -6
View File
@@ -11,7 +11,7 @@
#
import sys
import syslog
import logging
import locale
import gettext
@@ -67,7 +67,6 @@ 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:
@@ -76,7 +75,7 @@ class CLI(UI):
def warning(self, msg, verbose = False):
msg = unicode(msg)
syslog.syslog(syslog.LOG_WARNING, msg)
logging.warning(msg)
if ctx.get_option('no_color'):
self.output(_('Warning: ') + msg + '\n', err=True, verbose=verbose)
else:
@@ -84,7 +83,7 @@ class CLI(UI):
def error(self, msg):
msg = unicode(msg)
syslog.syslog(syslog.LOG_ERROR, msg)
logging.error(msg)
if ctx.get_option('no_color'):
self.output(_('Error: ') + msg + '\n', err=True)
else:
@@ -93,7 +92,7 @@ class CLI(UI):
def action(self, msg, verbose = False):
#TODO: this seems quite redundant?
msg = unicode(msg)
syslog.syslog(syslog.LOG_INFO, msg)
logging.info(msg)
self.output(colorize(msg + '\n', 'green'))
def choose(self, msg, opts):
@@ -152,4 +151,4 @@ class CLI(UI):
msg = None
if msg:
self.output(colorize(msg + '\n', 'cyan'))
syslog.syslog(syslog.LOG_NOTICE, msg)
logging.info(msg)