]> err.no Git - dak/commitdiff
restore program name to log messages
authorAnsgar Burchardt <ansgar@debian.org>
Sat, 14 May 2011 19:58:03 +0000 (19:58 +0000)
committerAnsgar Burchardt <ansgar@debian.org>
Sat, 14 May 2011 20:05:26 +0000 (20:05 +0000)
23 files changed:
dak/check_overrides.py
dak/clean_queues.py
dak/clean_suites.py
dak/contents.py
dak/control_overrides.py
dak/control_suite.py
dak/dak.py
dak/dominate.py
dak/external_overrides.py
dak/generate_filelist.py
dak/generate_packages_sources.py
dak/generate_packages_sources2.py
dak/generate_releases.py
dak/make_maintainers.py
dak/manage_build_queues.py
dak/metadata.py
dak/new_security_install.py
dak/override.py
dak/process_new.py
dak/process_policy.py
dak/process_upload.py
dak/update_db.py
daklib/daklog.py

index 7c924649deaed4a716ea8b583b04f0507fe970e3..a8e0f1d9eb6a172a4d1fa1629fd3690b8f6e57ed 100755 (executable)
@@ -341,9 +341,9 @@ def main ():
         priorities[entry] = name
 
     if not Options["No-Action"]:
-        Logger = daklog.Logger(cnf, "check-overrides")
+        Logger = daklog.Logger("check-overrides")
     else:
-        Logger = daklog.Logger(cnf, "check-overrides", 1)
+        Logger = daklog.Logger("check-overrides", 1)
 
     for osuite in cnf.SubTree("Check-Overrides::OverrideSuites").List():
         if "1" != cnf["Check-Overrides::OverrideSuites::%s::Process" % osuite]:
index f6964508a5b7e76a71f0c7347e5a0d441cdf44a1..474fe390cacbb1dbdcc36da812bf44f8715e78bf 100755 (executable)
@@ -193,7 +193,7 @@ def main ():
     if Options["Help"]:
         usage()
 
-    Logger = daklog.Logger(cnf, 'clean-queues', Options['No-Action'])
+    Logger = daklog.Logger('clean-queues', Options['No-Action'])
 
     init(cnf)
 
index ab1e76d778be1e3f9e91e84c77c1624360fa8545..5e41d372785a117e44c7ac0393afc085dc410601 100755 (executable)
@@ -426,7 +426,7 @@ def main():
     if Options["Help"]:
         usage()
 
-    Logger = daklog.Logger(cnf, "clean-suites", debug=Options["No-Action"])
+    Logger = daklog.Logger("clean-suites", debug=Options["No-Action"])
 
     session = DBConn().session()
 
index c2d04eb697dd683c176ebe6e1f4581887b43893a..76effc1d91306069203f498cd4169488c3643862 100755 (executable)
@@ -85,14 +85,14 @@ OPTIONS for scan-source and scan-binary
 ################################################################################
 
 def write_all(cnf, suite_names = [], component_names = [], force = None):
-    Logger = daklog.Logger(cnf.Cnf, 'contents generate')
+    Logger = daklog.Logger('contents generate')
     ContentsWriter.write_all(Logger, suite_names, component_names, force)
     Logger.close()
 
 ################################################################################
 
 def binary_scan_all(cnf, limit):
-    Logger = daklog.Logger(cnf.Cnf, 'contents scan-binary')
+    Logger = daklog.Logger('contents scan-binary')
     result = BinaryContentsScanner.scan_all(limit)
     processed = '%(processed)d packages processed' % result
     remaining = '%(remaining)d packages remaining' % result
@@ -102,7 +102,7 @@ def binary_scan_all(cnf, limit):
 ################################################################################
 
 def source_scan_all(cnf, limit):
-    Logger = daklog.Logger(cnf.Cnf, 'contents scan-source')
+    Logger = daklog.Logger('contents scan-source')
     result = SourceContentsScanner.scan_all(limit)
     processed = '%(processed)d packages processed' % result
     remaining = '%(remaining)d packages remaining' % result
index befc35d277e3d505e3a77836f2f174fdd2876709..803c8951d07e65b5f9f9ed5a8f7d6b3bf9fcf940 100755 (executable)
@@ -353,7 +353,7 @@ def main ():
             utils.warn("In No-Action Mode")
             action = False
 
-        Logger = daklog.Logger(cnf.Cnf, "control-overrides", mode)
+        Logger = daklog.Logger("control-overrides", mode)
         if file_list:
             for f in file_list:
                 process_file(utils.open_file(f), suite, component, otype, mode, action, session)
index 740b88365d6b630580f6c0904f6560b52c7a0139..ed4f6b1ace28e3dcb255cbfe9a48d3c17b1409f7 100755 (executable)
@@ -424,7 +424,7 @@ def main ():
     if action == "list":
         get_list(suite, session)
     else:
-        Logger = daklog.Logger(cnf.Cnf, "control-suite")
+        Logger = daklog.Logger("control-suite")
         if file_list:
             for f in file_list:
                 process_file(utils.open_file(f), suite, action, session, britney, force)
index b8b9f62d651307ba47f79176fc1c052e54c78b52..2a3c230893db82d7d3617dcdd7e964a93a2679e5 100755 (executable)
@@ -178,7 +178,7 @@ def main():
 
 
     try:
-        logger = Logger(Config(), 'dak top-level', print_starting=False)
+        logger = Logger('dak top-level', print_starting=False)
     except CantOpenError:
         logger = None
 
index 7bb74c6728ff12a448bd4fadd418da48dfb7dbf5..483ab28ab9e7c0f279f9fad6ac0b6ad7db5f3d6f 100755 (executable)
@@ -136,7 +136,7 @@ def main():
     Options = cnf.SubTree("Obsolete::Options")
     if Options['Help']:
         usage()
-    Logger = daklog.Logger(cnf.Cnf, "dominate")
+    Logger = daklog.Logger("dominate")
     session = DBConn().session()
     for suite_name in utils.split_args(Options['Suite']):
         suite = session.query(Suite).filter_by(suite_name = suite_name).one()
index 9e212061691004c55b5477ccc6637ef140edd438..6072c5a65196aa33a5d28c58c129338bc52c322f 100755 (executable)
@@ -125,7 +125,7 @@ def main():
     if Options.has_key("Force") and Options["Force"]:
         force = True
 
-    logger = daklog.Logger(cnf, 'external-overrides')
+    logger = daklog.Logger('external-overrides')
 
     command = args[0]
     if command in ('import', 'i'):
index 98d239c58aaeb805bdbadf9b25d086805aa101a4..7823295f5344b9874ef934e7e13c1eb6008c8595 100755 (executable)
@@ -132,7 +132,7 @@ Incremental mode appends only newer files to existing lists."""
 
 def main():
     cnf = Config()
-    Logger = daklog.Logger(cnf, 'generate-filelist')
+    Logger = daklog.Logger('generate-filelist')
     Arguments = [('h', "help",         "Filelist::Options::Help"),
                  ('s', "suite",        "Filelist::Options::Suite", "HasArg"),
                  ('c', "component",    "Filelist::Options::Component", "HasArg"),
index 5ef036dad4beafbba80bb3e13d1cb988fb6e7242..e78466fc96de24dd8466804a5935a4ca1f9aa186 100755 (executable)
@@ -468,7 +468,7 @@ def main ():
     if Options["Help"]:
         usage()
 
-    Logger = daklog.Logger(cnf, 'generate-packages-sources')
+    Logger = daklog.Logger('generate-packages-sources')
 
     session = DBConn().session()
 
index f3c843b53e29fa0ffd8c95444ee8369c4a12ddea..d29e0317f57890f18dd3f63d8e8e30b5500eb498 100755 (executable)
@@ -255,7 +255,7 @@ def main():
     if Options.has_key("Help"):
         usage()
 
-    logger = daklog.Logger(cnf, 'generate-packages-sources2')
+    logger = daklog.Logger('generate-packages-sources2')
 
     session = DBConn().session()
 
index 3006364602517c17466c075afa82efc0ee7fed56..0a394274d577e0142b8a70fc0a9d99e1eb8be0fa 100755 (executable)
@@ -306,7 +306,7 @@ def main ():
     if Options["Help"]:
         usage()
 
-    Logger = daklog.Logger(cnf, 'generate-releases')
+    Logger = daklog.Logger('generate-releases')
 
     session = DBConn().session()
 
index 0733f3bc3d46de3020701019dd42164cfa919ee0..8e93f8af920e0a03d8810e29f6b490a535f35ec3 100755 (executable)
@@ -77,7 +77,7 @@ def main():
     if Options["Help"]:
         usage()
 
-    Logger = daklog.Logger(cnf.Cnf, 'make-maintainers')
+    Logger = daklog.Logger('make-maintainers')
     session = DBConn().session()
 
     # dictionary packages to maintainer names
index e9486adfcdbf87ea3313f95cecb39f096a577067..a292b4ae752afb73bd9e24f823588db1966c987e 100755 (executable)
@@ -73,7 +73,7 @@ def main ():
     if Options["Help"]:
         usage()
 
-    Logger = daklog.Logger(cnf, 'manage-build-queues', Options['No-Action'])
+    Logger = daklog.Logger('manage-build-queues', Options['No-Action'])
 
     starttime = datetime.now()
 
index f40c9431557599951903a52c01bb07d6130f88ac..1fe32110752e65b385dcfad91c1f7d170b56d12b 100755 (executable)
@@ -66,7 +66,7 @@ OPTIONS for scan
 ################################################################################
 
 def scan_all(cnf, mode, limit):
-    Logger = daklog.Logger(cnf.Cnf, 'metadata scan (%s)' % mode)
+    Logger = daklog.Logger('metadata scan (%s)' % mode)
     result = MetadataScanner.scan_all(mode, limit)
     processed = '%(processed)d %(type)s processed' % result
     remaining = '%(remaining)d %(type)s remaining' % result
index 2048e215ea3da3ef0db43d0136171dbf8c0561ab..2dd2820f2b8fee4d715fec1e703eb9d1f0ea9600 100755 (executable)
@@ -155,7 +155,7 @@ def main():
         Options["Sudo"] = ""
 
     if not Options["Sudo"] and not Options["No-Action"]:
-        Logger = daklog.Logger(cnf.Cnf, "security-install")
+        Logger = daklog.Logger("security-install")
 
     session = DBConn().session()
 
index 13a277dbdc542e5de65b85a291a0befe0ae739f7..3d2a9aba20b100e745a06b129c32e194960bdfe2 100755 (executable)
@@ -254,7 +254,7 @@ def main ():
 
     game_over()
 
-    Logger = daklog.Logger(cnf.Cnf, "override")
+    Logger = daklog.Logger("override")
 
     dsc_otype_id = get_override_type('dsc').overridetype_id
 
index 11e9bf48efc9b5e968f2661ebcf4e2272e90df44..5899a9ccdb211fd9f5563d636b09ff136f968582 100755 (executable)
@@ -784,7 +784,7 @@ def main():
 
     if not Options["No-Action"]:
         try:
-            Logger = daklog.Logger(cnf, "process-new")
+            Logger = daklog.Logger("process-new")
         except CantOpenError, e:
             Options["Trainee"] = "True"
 
index dfe538fb127be7b9a556f919fcd72740468da1bb..94e274687bcd0902f652c91db8756c298f94587d 100755 (executable)
@@ -141,7 +141,7 @@ def main():
 
     if not Options["No-Action"]:
         try:
-            Logger = daklog.Logger(cnf, "process-policy")
+            Logger = daklog.Logger("process-policy")
         except CantOpenError, e:
             Logger = None
 
index 12e25a3352316be03144f6c12f9d1facfa1c98fb..f74993ce3e7e1dbc185509d320ef3bcc5adecfb9 100755 (executable)
@@ -469,7 +469,7 @@ def main():
             log_urgency = True
             UrgencyLog()
 
-    Logger = daklog.Logger(cnf, "process-upload", Options["No-Action"])
+    Logger = daklog.Logger("process-upload", Options["No-Action"])
 
     # If we have a directory flag, use it to find our files
     if cnf["Dinstall::Options::Directory"] != "":
index 02ded358de735113b6bb810ea515548408a40655..91c8211f0f5812afa4173b05f148b6255f020934 100755 (executable)
@@ -119,7 +119,7 @@ Updates dak's database schema to the lastest version. You should disable crontab
         # Ok, try and find the configuration table
         print "Determining dak database revision ..."
         cnf = Config()
-        logger = Logger(cnf.Cnf, 'update-db')
+        logger = Logger('update-db')
 
         try:
             # Build a connect string
index 856dc84103b385f5be41f799c3543ad8ad433d3b..7ececa560ebc74f5405dfc8f73a571b77691a9ca 100644 (file)
@@ -36,28 +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):
-            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"]
@@ -79,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