Commit d7c62d16 authored by Ansgar's avatar Ansgar

restore program name to log messages

parent 69167758
......@@ -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]:
......
......@@ -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)
......
......@@ -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()
......
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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()
......
......@@ -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'):
......
......@@ -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"),
......
......@@ -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()
......
......@@ -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()
......
......@@ -306,7 +306,7 @@ def main ():
if Options["Help"]:
usage()
Logger = daklog.Logger(cnf, 'generate-releases')
Logger = daklog.Logger('generate-releases')
session = DBConn().session()
......
......@@ -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
......
......@@ -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()
......
......@@ -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
......
......@@ -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()
......
......@@ -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
......
......@@ -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"
......
......@@ -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
......
......@@ -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"] != "":
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment