* fix: make the other levels work
* clean up the log without calling logging.shutdown(), this should make it possible to mix pisi logger with other loggers, and make it properly re-entrant. so much for an easy to use api!
This commit is contained in:
+5
-2
@@ -70,11 +70,13 @@ def init(database = True, write = True,
|
|||||||
|
|
||||||
if os.access('/var/log', os.W_OK):
|
if os.access('/var/log', os.W_OK):
|
||||||
handler = logging.handlers.RotatingFileHandler('/var/log/pisi.log')
|
handler = logging.handlers.RotatingFileHandler('/var/log/pisi.log')
|
||||||
handler.setLevel(logging.DEBUG)
|
#handler.setLevel(logging.DEBUG)
|
||||||
formatter = logging.Formatter('%(asctime)-12s: %(levelname)-8s %(message)s')
|
formatter = logging.Formatter('%(asctime)-12s: %(levelname)-8s %(message)s')
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
ctx.log = logging.getLogger('pisi')
|
ctx.log = logging.getLogger('pisi')
|
||||||
ctx.log.addHandler(handler)
|
ctx.log.addHandler(handler)
|
||||||
|
ctx.loghandler = handler
|
||||||
|
ctx.log.setLevel(logging.DEBUG)
|
||||||
else:
|
else:
|
||||||
ctx.log = None
|
ctx.log = None
|
||||||
|
|
||||||
@@ -116,7 +118,8 @@ def finalize():
|
|||||||
if ctx.initialized:
|
if ctx.initialized:
|
||||||
|
|
||||||
if ctx.log:
|
if ctx.log:
|
||||||
logging.shutdown()
|
ctx.loghandler.flush()
|
||||||
|
ctx.log.removeHandler(ctx.loghandler)
|
||||||
|
|
||||||
pisi.repodb.finalize()
|
pisi.repodb.finalize()
|
||||||
pisi.installdb.finalize()
|
pisi.installdb.finalize()
|
||||||
|
|||||||
Reference in New Issue
Block a user