Catch warnings

This commit is contained in:
Ruud
2012-02-17 11:11:28 +01:00
parent 456b44e80f
commit 02fab2d04d
3 changed files with 9 additions and 0 deletions
+3
View File
@@ -22,6 +22,9 @@ class CPLog(object):
def error(self, msg):
self.logger.error(self.addContext(msg))
def warning(self, msg):
self.logger.warning(self.addContext(msg))
def critical(self, msg):
self.logger.critical(self.addContext(msg), exc_info = 1)
@@ -66,6 +66,7 @@ Page.Log = new Class({
text = text.replace(/\u001b\[31m/gi, '</span><span class="error">')
text = text.replace(/\u001b\[36m/gi, '</span><span class="debug">')
text = text.replace(/\u001b\[33m/gi, '</span><span class="debug">')
text = text.replace(/\u001b\[0m\n/gi, '</span><span class="time">')
text = text.replace(/\u001b\[0m/gi, '</span><span>')
+5
View File
@@ -11,6 +11,7 @@ import logging
import os.path
import sys
import time
import warnings
def getOptions(base_path, args):
@@ -133,6 +134,10 @@ def runCouchPotato(options, base_path, args, desktop = None):
log = CPLog(__name__)
log.debug('Started with options %s' % options)
def customwarn(message, category, filename, lineno, file = None, line = None):
log.warning('%s %s %s line:%s' % (category, message, filename, lineno))
warnings.showwarning = customwarn
# Load configs & plugins
loader = Env.get('loader')