Action: store a logger object in each Action.
authorMatthijs Kooijman <matthijs@stdin.nl>
Sat, 7 Aug 2010 18:53:20 +0000 (20:53 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Sat, 7 Aug 2010 18:53:40 +0000 (20:53 +0200)
This will allow log messages to include the action they originate from
in the future.

src/lib/backupninja/handlers/__init__.py
src/lib/backupninja/handlers/test.py

index 29dc75631823ed79d5ecda18b99698d6dcacb782..484677171e0e72ec57250bbdfeaf3b554acf226e 100644 (file)
@@ -55,6 +55,10 @@ class Action(object):
         # Assume we'll run succesfully. If anything fails in the
         # meanwhile, set this to True.
         self.failed = False
         # Assume we'll run succesfully. If anything fails in the
         # meanwhile, set this to True.
         self.failed = False
+        # A logger object for this action. In the future, this might
+        # become a specific logger, that includes the action name and
+        # type.
+        self.log = log
 
     def run(self, **kwargs):
         """
 
     def run(self, **kwargs):
         """
index 3b8c5d42640da0eca49bbe2aec59b2c474780afd..33a4f47d11ce535b9e293a08a489293fd17e9031 100644 (file)
 
 """ Testing handler that logs a configurable message """
 
 
 """ Testing handler that logs a configurable message """
 
-import logging as log
-
 from backupninja.handlers import Action
 
 class TestAction(Action):
     def run(self, **kwargs):
 from backupninja.handlers import Action
 
 class TestAction(Action):
     def run(self, **kwargs):
-        log.info(self.conf.get('main', 'message'))
+        self.log.info(self.conf.get('main', 'message'))
         
 handler = TestAction
         
 handler = TestAction