log.c revision 1.11
1/*	$NetBSD: log.c,v 1.11 2020/05/25 20:47:32 christos Exp $	*/
2
3#include <config.h>
4
5#include "log.h"
6
7const char *progname;		/* for msyslog use too */
8
9static int counter = 0;
10
11static void cleanup_log(void);
12
13void
14sntp_init_logging(
15	const char *prog
16	)
17{
18
19	msyslog_term = TRUE;
20	init_logging(prog, 0, FALSE);
21	msyslog_term_pid = FALSE;
22	msyslog_include_timestamp = FALSE;
23}
24
25void
26open_logfile(
27	const char *logfile
28	)
29{
30	change_logfile(logfile, FALSE);
31	counter = 1; //counter++;
32	atexit(cleanup_log);
33}
34
35//not sure about this. Are the atexit() functions called by FIFO or LIFO order? The end result is PROBABLY the same
36static void
37cleanup_log(void)
38{
39	//counter--;
40	//if(counter <= 0){
41	if(counter == 1){
42		syslogit = TRUE;
43		fflush(syslog_file);
44		fclose(syslog_file);
45		syslog_file = NULL;
46		counter = 0;
47	}
48}
49