From daa3e224a3a3d25d6cd55b2416e9c236c1b4f59d Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 17 Sep 2014 14:46:57 +0200 Subject: Fix logging in brain.py --- client/brain.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/client/brain.py b/client/brain.py index a1fdea4..f197bc4 100644 --- a/client/brain.py +++ b/client/brain.py @@ -5,17 +5,6 @@ import pkgutil import importlib import jasperpath - -def logError(): - logger = logging.getLogger('jasper') - fh = logging.FileHandler('jasper.log') - fh.setLevel(logging.WARNING) - formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') - fh.setFormatter(formatter) - logger.addHandler(fh) - logger.error('Failed to execute module', exc_info=True) - - class Brain(object): def __init__(self, mic, profile): @@ -33,6 +22,7 @@ class Brain(object): self.mic = mic self.profile = profile self.modules = self.get_modules() + self._logger = logging.getLogger(__name__) @classmethod def get_modules(cls): @@ -67,7 +57,7 @@ class Brain(object): module.handle(text, self.mic, self.profile) break except: - logError() + self._logger.error('Failed to execute module', exc_info=True) self.mic.say( "I'm sorry. I had some trouble with that operation. Please try again later.") break -- cgit v1.3.1