xref: /netbsd-src/external/bsd/ntp/dist/sntp/log.c (revision ea66d79595ea38b5dd51f2a7f92eb38e5bc820a5)
1 /*	$NetBSD: log.c,v 1.7 2014/12/19 20:43:18 christos Exp $	*/
2 
3 #include <config.h>
4 
5 #include "log.h"
6 
7 char *progname;		/* for msyslog use too */
8 
9 static void cleanup_log(void);
10 
11 void
12 sntp_init_logging(
13 	const char *prog
14 	)
15 {
16 	msyslog_term = TRUE;
17 	init_logging(prog, 0, FALSE);
18 	msyslog_term_pid = FALSE;
19 	msyslog_include_timestamp = FALSE;
20 }
21 
22 void
23 open_logfile(
24 	const char *logfile
25 	)
26 {
27 	change_logfile(logfile, FALSE);
28 	atexit(cleanup_log);
29 }
30 
31 
32 static void
33 cleanup_log(void)
34 {
35 	syslogit = TRUE;
36 	fflush(syslog_file);
37 	fclose(syslog_file);
38 	syslog_file = NULL;
39 }
40