summaryrefslogtreecommitdiff
path: root/portato/log.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--portato/log.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/portato/log.py b/portato/log.py
index 486aa51..b6462e9 100644
--- a/portato/log.py
+++ b/portato/log.py
@@ -3,7 +3,7 @@
# File: portato/log.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
-# Copyright (C) 2006-2009 René 'Necoro' Neumann
+# Copyright (C) 2006-2010 René 'Necoro' Neumann
# This is free software. You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
@@ -100,3 +100,13 @@ def start(file = True):
def set_log_level (lvl):
for h in streamhandlers:
h.setLevel(lvl)
+
+# embed warnings in our logging functionality
+import warnings
+def showwarnings(msg, cat, filename, lineno, file = None, line = None):
+ msg = warnings.formatwarning(msg, cat, filename, lineno, line)
+
+ record = logging.LogRecord("portatoLogger", logging.WARNING, filename, lineno, "Portage Warning: %s", (msg,), None)
+ logging.getLogger("portatoLogger").handle(record)
+
+warnings.showwarning = showwarnings