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