File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / ntp / sntp / log.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:08:38 2012 UTC (12 years, 2 months ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5

    1: #include <config.h>
    2: 
    3: #include "log.h"
    4: 
    5: char *progname = "sntp";	/* for msyslog use too */
    6: 
    7: static void cleanup_log(void);
    8: 
    9: void
   10: init_logging(void)
   11: {
   12: 	openlog(progname, LOG_PID | LOG_CONS, OPENLOG_FAC);
   13: 	msyslog_term = TRUE;
   14: }
   15: 
   16: 
   17: void
   18: open_logfile(
   19: 	const char *logfile
   20: 	)
   21: {
   22: 	syslog_file = fopen(logfile, "a");	
   23: 	if (syslog_file == NULL) {
   24: 		msyslog(LOG_ERR, "sntp: Cannot open logfile %s",
   25: 			logfile);
   26: 		return;
   27: 	}
   28: 	syslogit = FALSE;
   29: 	atexit(cleanup_log);
   30: }
   31: 
   32: 
   33: static void
   34: cleanup_log(void)
   35: {
   36: 	syslogit = TRUE;
   37: 	fflush(syslog_file);
   38: 	fclose(syslog_file);
   39: 	syslog_file = NULL;
   40: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>