utils.Daemonize(logfile=constants.LOG_MASTERDAEMON,
noclose_fds=[master.fileno()])
- logger.SetupDaemon(constants.LOG_MASTERDAEMON, debug=options.debug)
+ logger.SetupDaemon(constants.LOG_MASTERDAEMON, debug=options.debug,
+ stderr_logging=not options.fork)
logging.info("ganeti master daemon startup")
if options.fork:
utils.Daemonize(logfile=constants.LOG_NODESERVER)
- logger.SetupDaemon(logfile=constants.LOG_NODESERVER, debug=options.debug)
+ logger.SetupDaemon(logfile=constants.LOG_NODESERVER, debug=options.debug,
+ stderr_logging=not options.fork)
logging.info("ganeti node daemon startup")
global _EXIT_GANETI_NODED
root_logger.addHandler(stderr_file)
-def SetupDaemon(logfile, debug=False):
+def SetupDaemon(logfile, debug=False, stderr_logging=False):
"""Configures the logging module for daemons
"""
if debug:
- fmt = "%(asctime)s: %(levelname)s %(pathname)s:%(lineno)s %(message)s"
+ fmt = "%(asctime)s: %(levelname)s %(module)s:%(lineno)s %(message)s"
else:
fmt = "%(asctime)s: %(levelname)s %(message)s"
formatter = logging.Formatter(fmt)
root_logger = logging.getLogger("")
root_logger.setLevel(logging.NOTSET)
root_logger.addHandler(logfile_handler)
- root_logger.addHandler(stderr_handler)
+ if stderr_logging:
+ root_logger.addHandler(stderr_handler)
# Backwards compatibility