for key, val in override.iteritems():
setattr(options, key, val)
- utils.SetupLogging(constants.LOG_COMMANDS, debug=options.debug,
- stderr_logging=True, program=binary)
+ utils.SetupLogging(constants.LOG_COMMANDS, binary, debug=options.debug,
+ stderr_logging=True)
if old_cmdline:
logging.info("run with arguments '%s'", old_cmdline)
utils.WritePidFile(utils.DaemonPidFileName(daemon_name))
try:
try:
- utils.SetupLogging(logfile=constants.DAEMONS_LOGFILES[daemon_name],
+ utils.SetupLogging(constants.DAEMONS_LOGFILES[daemon_name], daemon_name,
debug=options.debug,
stderr_logging=not options.fork,
multithreaded=multithreaded,
- program=daemon_name,
syslog=options.syslog,
console_logging=console_logging)
if callable(prepare_fn):
"""
+import os.path
import logging
import logging.handlers
return logging.Formatter("".join(parts))
-def SetupLogging(logfile, debug=0, stderr_logging=False, program="",
+def SetupLogging(logfile, program, debug=0, stderr_logging=False,
multithreaded=False, syslog=constants.SYSLOG_USAGE,
console_logging=False):
"""Configures the logging module.
@type logfile: str
@param logfile: the filename to which we should log
+ @type program: str
+ @param program: the name under which we should log messages
@type debug: integer
@param debug: if greater than zero, enable debug messages, otherwise
only those at C{INFO} and above level
@type stderr_logging: boolean
@param stderr_logging: whether we should also log to the standard error
- @type program: str
- @param program: the name under which we should log messages
@type multithreaded: boolean
@param multithreaded: if True, will add the thread name to the log file
@type syslog: string
syslog/stderr logging is disabled
"""
- formatter = _GetLogFormatter(program, multithreaded, debug, False)
- syslog_fmt = _GetLogFormatter(program, multithreaded, debug, True)
+ progname = os.path.basename(program)
+
+ formatter = _GetLogFormatter(progname, multithreaded, debug, False)
+ syslog_fmt = _GetLogFormatter(progname, multithreaded, debug, True)
root_logger = logging.getLogger("")
root_logger.setLevel(logging.NOTSET)
# C0103: Invalid name ganeti-watcher
import os
+import os.path
import sys
import time
import logging
print >> sys.stderr, ("Usage: %s [-f] " % sys.argv[0])
return constants.EXIT_FAILURE
- utils.SetupLogging(constants.LOG_WATCHER, debug=options.debug,
- stderr_logging=options.debug)
+ utils.SetupLogging(constants.LOG_WATCHER, sys.argv[0],
+ debug=options.debug, stderr_logging=options.debug)
if ShouldPause() and not options.ignore_pause:
logging.debug("Pause has been set, exiting")
"""Main function.
"""
- utils.SetupLogging(constants.LOG_BURNIN, debug=False, stderr_logging=True)
+ utils.SetupLogging(constants.LOG_BURNIN, sys.argv[0],
+ debug=False, stderr_logging=True)
return Burner().BurninCluster()