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 ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5

#include <config.h>

#include "log.h"

char *progname = "sntp";	/* for msyslog use too */

static void cleanup_log(void);

void
init_logging(void)
{
	openlog(progname, LOG_PID | LOG_CONS, OPENLOG_FAC);
	msyslog_term = TRUE;
}


void
open_logfile(
	const char *logfile
	)
{
	syslog_file = fopen(logfile, "a");	
	if (syslog_file == NULL) {
		msyslog(LOG_ERR, "sntp: Cannot open logfile %s",
			logfile);
		return;
	}
	syslogit = FALSE;
	atexit(cleanup_log);
}


static void
cleanup_log(void)
{
	syslogit = TRUE;
	fflush(syslog_file);
	fclose(syslog_file);
	syslog_file = NULL;
}

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