* 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 os
import sys import sys
import syslog import logging
from os.path import exists from os.path import exists
import bsddb3.db as db import bsddb3.db as db
@@ -66,7 +66,11 @@ def init(database = True, write = True,
else: else:
ctx.ui = ui 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 # If given define stdout and stderr. Needed by buildfarm currently
# but others can benefit from this too. # but others can benefit from this too.
@@ -105,7 +109,7 @@ def init(database = True, write = True,
def finalize(): def finalize():
if ctx.initialized: if ctx.initialized:
syslog.closelog() logging.shutdown()
pisi.repodb.finalize() pisi.repodb.finalize()
pisi.installdb.finalize() pisi.installdb.finalize()
+5 -6
View File
@@ -11,7 +11,7 @@
# #
import sys import sys
import syslog import logging
import locale import locale
import gettext import gettext
@@ -67,7 +67,6 @@ 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:
@@ -76,7 +75,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) logging.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:
@@ -84,7 +83,7 @@ class CLI(UI):
def error(self, msg): def error(self, msg):
msg = unicode(msg) msg = unicode(msg)
syslog.syslog(syslog.LOG_ERROR, msg) logging.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:
@@ -93,7 +92,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) logging.info(msg)
self.output(colorize(msg + '\n', 'green')) self.output(colorize(msg + '\n', 'green'))
def choose(self, msg, opts): def choose(self, msg, opts):
@@ -152,4 +151,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) logging.info(msg)