]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/daklog.py
auto-decruft: Expand NVI in cmd line argument names
[dak.git] / daklib / daklog.py
index 856dc84103b385f5be41f799c3543ad8ad433d3b..05ca9b1adaab9770ae6048956b1df1fda00a5e13 100644 (file)
@@ -36,34 +36,26 @@ 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):
-            from daklib.config import Config
-            self.initialised = True
-
-            # To be backwards compatibile, dump the first argument if it's a
-            # Config object.  TODO: Fix up all callers and remove this
-            if len(args) > 0 and isinstance(args[0], Config):
-                args = list(args)
-                args.pop(0)
-
-            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"]
         if not os.path.exists(logdir):
             umask = os.umask(00000)
-            os.makedirs(logdir, 02775)
+            os.makedirs(logdir, 0o2775)
             os.umask(umask)
 
         # Open the logfile
@@ -73,15 +65,12 @@ class Logger(object):
         if debug:
             logfile = sys.stderr
         else:
-            umask = os.umask(00002)
+            umask = os.umask(0o0002)
             logfile = utils.open_file(logfilename, 'a')
             os.umask(umask)
 
         self.logfile = logfile
 
-        if print_starting:
-            self.log(["program start"])
-
     def log (self, details):
         "Log an event"
         # Prepend timestamp, program name, and user name