Browse Source

added some more info messages, imporved logging

Helmut Pozimski 11 years ago
parent
commit
6e17e8788b
1 changed files with 10 additions and 10 deletions
  1. 10 10
      stdd

+ 10 - 10
stdd

@@ -39,19 +39,15 @@ parser.add_option("-c", "--config", dest="config", help="define an\
 	alternative path to the configuration file")
 	alternative path to the configuration file")
 (options, arguments) = parser.parse_args()
 (options, arguments) = parser.parse_args()
 
 
-""" define a sighandler to properly catch signals """
-
-
-run = True
 
 
 
 
 """ define a sighandler to properly catch signals """
 """ define a sighandler to properly catch signals """
 
 
 def sighandler(signum, frame):
 def sighandler(signum, frame):
 	if signum == 2:
 	if signum == 2:
-		pass
+		logger.info("received SIGINT, stopping daemon")
 	elif signum == 15:
 	elif signum == 15:
-		pass
+		logger.info("received SIGTERM, stopping daemon")
 	display.writeDigit(0, 0)
 	display.writeDigit(0, 0)
 	display.writeDigit(1, 0)
 	display.writeDigit(1, 0)
 	display.writeDigit(3, 0)
 	display.writeDigit(3, 0)
@@ -60,7 +56,7 @@ def sighandler(signum, frame):
 		if daemon.Stop() is True:
 		if daemon.Stop() is True:
 			sys.exit(0)
 			sys.exit(0)
 		else:
 		else:
-			#TODO: Log error message
+			logger.error("stopping daemon failed, PID file was not deleted!")
 			sys,exit(1)
 			sys,exit(1)
 	
 	
 """ create the configuration object according to the given parameters and
 """ create the configuration object according to the given parameters and
@@ -90,10 +86,14 @@ elif config.syslog_level == "error":
 else:
 else:
 	logger.setLevel(logging.INFO)
 	logger.setLevel(logging.INFO)
 
 
-syslog_handler = logging.handlers.SysLogHandler("/dev/log")
+if config.syslog_facility == "user":
+	syslog_handler = logging.handlers.SysLogHandler("/dev/log")
+elif config.syslog_facility == "daemon":
+	syslog_handler = logging.handlers.SysLogHandler("/dev/log",
+		facility=logging.handlers.SysLogHandler.LOG_DAEMON)
 console_handler = logging.StreamHandler()
 console_handler = logging.StreamHandler()
 
 
-formatter = logging.Formatter("%%(name)s:  %(message)s")
+formatter = logging.Formatter("%(name)s[os.getuid()]:  %(message)s")
 
 
 syslog_handler.setFormatter(formatter)
 syslog_handler.setFormatter(formatter)
 console_handler.setFormatter(formatter)
 console_handler.setFormatter(formatter)
@@ -145,7 +145,7 @@ else:
 	display.setBrightness(config.brightness_low)
 	display.setBrightness(config.brightness_low)
 """Define the main loop"""
 """Define the main loop"""
 def main():
 def main():
-	while run is True:
+	while True:
 		date_now = datetime.datetime.now()
 		date_now = datetime.datetime.now()
 		minute = date_now.minute
 		minute = date_now.minute
 		hour = date_now.hour
 		hour = date_now.hour