diff options
author | Joel Andres Granados <jgranado@redhat.com> | 2008-02-01 18:53:42 +0100 |
---|---|---|
committer | Joel Andres Granados <jgranado@redhat.com> | 2008-02-01 18:53:42 +0100 |
commit | e9c3d3cb51a7753a94f926154c192fba863cc395 (patch) | |
tree | b76c01969ce67392290c8e4074e94e91cd827930 | |
parent | 7a4683d8c30f89e7eb5a9cb3cbacee4da6f77ac6 (diff) | |
download | firstaidkit-e9c3d3cb51a7753a94f926154c192fba863cc395.tar.gz firstaidkit-e9c3d3cb51a7753a94f926154c192fba863cc395.tar.xz firstaidkit-e9c3d3cb51a7753a94f926154c192fba863cc395.zip |
The log in __builtins__ might have some strange sideeffects.
-rwxr-xr-x | firstaidkit | 4 | ||||
-rw-r--r-- | pyfirstaidkit/__init__.py | 25 | ||||
-rw-r--r-- | pyfirstaidkit/interpret.py | 2 | ||||
-rw-r--r-- | pyfirstaidkit/plugins.py | 2 |
4 files changed, 14 insertions, 19 deletions
diff --git a/firstaidkit b/firstaidkit index 90b25e5..f89adb0 100755 --- a/firstaidkit +++ b/firstaidkit @@ -22,7 +22,7 @@ from threading import Thread from pyfirstaidkit import Tasker from pyfirstaidkit import Config from pyfirstaidkit import reporting -from pyfirstaidkit import FAKLogger +from pyfirstaidkit import Logger class Flags: print_config = False @@ -110,7 +110,7 @@ if __name__=="__main__": Config.lock() # Now that the config is locked, initialize log for plugin system. - FAKLogger(Config) + pyfirstaidkit.initLogger(Config) singlerun = Tasker(Config) diff --git a/pyfirstaidkit/__init__.py b/pyfirstaidkit/__init__.py index a92e797..a9a33f4 100644 --- a/pyfirstaidkit/__init__.py +++ b/pyfirstaidkit/__init__.py @@ -19,21 +19,16 @@ from interpret import Tasker from configuration import Config #from log import Logger import logging -import __builtin__ import sys -class FAKLogger: - """Describes the logger that will be used only by the pluginsystem. - - When instanciated it will put the logger in builtins so it is reachable - from everywhere in the code. """ - def __init__(self, config): - Logger = logging.getLogger("firstaidkit") - Logger.setLevel(logging.DEBUG) - if config.log.method == "stdout": - Logger.addHandler(logging.StreamHandler(sys.stdout)) - else: - # if nothing else matches we just put it into the file. - Logger.addHandler(logging.FileHandler(config.log.filename)) - __builtin__.Logger = Logger +Logger=None +def initLogger(config=None): + """We want to initialize loger when we have the filename.""" + Logger = logging.getLogger("firstaidkit") + Logger.setLevel(logging.DEBUG) + if config.log.method == "stdout" or config.log.method == None: + Logger.addHandler(logging.StreamHandler(sys.stdout)) + else: + # if nothing else matches we just put it into the file. + Logger.addHandler(logging.FileHandler(config.log.filename)) diff --git a/pyfirstaidkit/interpret.py b/pyfirstaidkit/interpret.py index 888756c..a103745 100644 --- a/pyfirstaidkit/interpret.py +++ b/pyfirstaidkit/interpret.py @@ -15,11 +15,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#from log import Logger from plugins import PluginSystem from reporting import Reports, TASKER import logging import copy +import Logger class RunDependencies(object): """Encapsulate flags used to control the dependencies between plugins""" diff --git a/pyfirstaidkit/plugins.py b/pyfirstaidkit/plugins.py index 5d4903a..5522fa9 100644 --- a/pyfirstaidkit/plugins.py +++ b/pyfirstaidkit/plugins.py @@ -21,7 +21,7 @@ from errors import * from copy import copy,deepcopy import FirstAidKit -#from log import Logger +import Logger import imp import os |