* fix: don't use basicconfig, instantiate handler manually, this
becomes re-entrant now, and works with build farm, but downside: info messages don't show up!
This commit is contained in:
+9
-10
@@ -17,6 +17,7 @@
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import logging.handlers
|
||||
from os.path import exists
|
||||
import bsddb3.db as db
|
||||
|
||||
@@ -67,17 +68,15 @@ def init(database = True, write = True,
|
||||
else:
|
||||
ctx.ui = ui
|
||||
|
||||
|
||||
if os.access('/var/log', os.W_OK):
|
||||
# FIXME: Breaks buildfarm
|
||||
#ctx.log = True
|
||||
ctx.log = False
|
||||
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')
|
||||
handler = logging.handlers.RotatingFileHandler('/var/log/pisi.log')
|
||||
handler.setLevel(logging.DEBUG)
|
||||
formatter = logging.Formatter('%(asctime)-12s: %(levelname)-8s %(message)s')
|
||||
handler.setFormatter(formatter)
|
||||
ctx.log = logging.getLogger('pisi')
|
||||
ctx.log.addHandler(handler)
|
||||
else:
|
||||
ctx.log = False
|
||||
ctx.log = None
|
||||
|
||||
# If given define stdout and stderr. Needed by buildfarm currently
|
||||
# but others can benefit from this too.
|
||||
@@ -118,7 +117,7 @@ def finalize():
|
||||
|
||||
if ctx.log:
|
||||
logging.shutdown()
|
||||
|
||||
|
||||
pisi.repodb.finalize()
|
||||
pisi.installdb.finalize()
|
||||
if ctx.filesdb != None:
|
||||
|
||||
@@ -76,7 +76,7 @@ class CLI(UI):
|
||||
def warning(self, msg, verbose = False):
|
||||
msg = unicode(msg)
|
||||
if ctx.log:
|
||||
logging.warning(msg)
|
||||
ctx.log.warning(msg)
|
||||
if ctx.get_option('no_color'):
|
||||
self.output(_('Warning: ') + msg + '\n', err=True, verbose=verbose)
|
||||
else:
|
||||
@@ -85,7 +85,7 @@ class CLI(UI):
|
||||
def error(self, msg):
|
||||
msg = unicode(msg)
|
||||
if ctx.log:
|
||||
logging.error(msg)
|
||||
ctx.log.error(msg)
|
||||
if ctx.get_option('no_color'):
|
||||
self.output(_('Error: ') + msg + '\n', err=True)
|
||||
else:
|
||||
@@ -95,7 +95,7 @@ class CLI(UI):
|
||||
#TODO: this seems quite redundant?
|
||||
msg = unicode(msg)
|
||||
if ctx.log:
|
||||
logging.info(msg)
|
||||
ctx.log.info(msg)
|
||||
self.output(colorize(msg + '\n', 'green'))
|
||||
|
||||
def choose(self, msg, opts):
|
||||
@@ -155,4 +155,4 @@ class CLI(UI):
|
||||
if msg:
|
||||
self.output(colorize(msg + '\n', 'cyan'))
|
||||
if ctx.log:
|
||||
logging.info(msg)
|
||||
ctx.log.info(msg)
|
||||
|
||||
Reference in New Issue
Block a user