X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdaklog.py;h=7ececa560ebc74f5405dfc8f73a571b77691a9ca;hb=50db22ea5f288daa39f81138a41a509d9a41cc3e;hp=a3b9b02bcfd82acc671b30c63a2b6d7d5c26e4aa;hpb=eb07a3a30ac1c5876f364c3aae8f7d5dbda63890;p=dak.git diff --git a/daklib/daklog.py b/daklib/daklog.py index a3b9b02b..7ececa56 100644 --- a/daklib/daklog.py +++ b/daklib/daklog.py @@ -36,20 +36,20 @@ class Logger(object): "Logger object" __shared_state = {} - def __init__(self, *args, **kwargs): + def __init__(self, program='unknown', debug=False, print_starting=True, include_pid=False): self.__dict__ = self.__shared_state - if not getattr(self, 'initialised', False): - self.initialised = True - self.__setup(*args, **kwargs) - - - def __setup(self, program='unknown', debug=False, print_starting=True, include_pid=False): - "Initialize a new Logger object" self.program = program self.debug = debug self.include_pid = include_pid + if not getattr(self, 'logfile', None): + self._open_log(debug) + + if print_starting: + self.log(["program start"]) + + def _open_log(self, debug): # Create the log directory if it doesn't exist from daklib.config import Config logdir = Config()["Dir::Log"] @@ -71,9 +71,6 @@ class Logger(object): self.logfile = logfile - if print_starting: - self.log(["program start"]) - def log (self, details): "Log an event" # Prepend timestamp, program name, and user name