From 7cc646921e15310e86807c26f8c6462b41362e58 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sat, 7 Aug 2010 20:53:20 +0200 Subject: [PATCH] Action: store a logger object in each Action. This will allow log messages to include the action they originate from in the future. --- src/lib/backupninja/handlers/__init__.py | 4 ++++ src/lib/backupninja/handlers/test.py | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/backupninja/handlers/__init__.py b/src/lib/backupninja/handlers/__init__.py index 29dc756..4846771 100644 --- a/src/lib/backupninja/handlers/__init__.py +++ b/src/lib/backupninja/handlers/__init__.py @@ -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 + # 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): """ diff --git a/src/lib/backupninja/handlers/test.py b/src/lib/backupninja/handlers/test.py index 3b8c5d4..33a4f47 100644 --- a/src/lib/backupninja/handlers/test.py +++ b/src/lib/backupninja/handlers/test.py @@ -21,12 +21,10 @@ """ Testing handler that logs a configurable message """ -import logging as log - 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 -- 2.30.2