/[svn]/hopm/branches/1.1.x/src/log.c
ViewVC logotype

Contents of /hopm/branches/1.1.x/src/log.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6971 - (show annotations)
Sat Dec 19 20:30:07 2015 UTC (4 years, 9 months ago) by michael
File MIME type: text/x-chdr
File size: 1930 byte(s)
- Add date_iso8601() and make use of it

1 /*
2 * Copyright (c) 2002 Erik Fears
3 * Copyright (c) 2014-2015 ircd-hybrid development team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18 * USA
19 */
20
21 #include "setup.h"
22
23 #include <stdio.h>
24 #include <errno.h>
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #include <string.h>
28 #include <time.h>
29
30 #include "log.h"
31 #include "main.h"
32 #include "misc.h"
33
34
35 FILE *logfile;
36 FILE *scanlogfile;
37
38 void
39 log_open(const char *filename)
40 {
41 logfile = fopen(filename, "a");
42
43 if (logfile == NULL)
44 {
45 perror("Cannot open log file. Aborting.");
46 exit(EXIT_FAILURE);
47 }
48 }
49
50 void
51 log_close(void)
52 {
53 fclose(logfile);
54 }
55
56 void
57 scanlog_open(const char *filename)
58 {
59 scanlogfile = fopen(filename, "a");
60
61 if (scanlogfile == NULL)
62 log_printf("Failed to open scan log file: %s", strerror(errno));
63 }
64
65 void
66 scanlog_close(void)
67 {
68 if (scanlogfile)
69 fclose(scanlogfile);
70 }
71
72 void
73 log_printf(const char *data, ...)
74 {
75 char data2[513];
76 va_list arglist;
77
78 if (OPT_DEBUG == 0 && logfile == NULL)
79 return;
80
81 va_start(arglist, data);
82 vsnprintf(data2, 512, data, arglist);
83 va_end(arglist);
84
85 if (OPT_DEBUG)
86 fprintf(stderr, "[%s] %s\n", date_iso8601(0), data2);
87 else
88 {
89 fprintf(logfile, "[%s] %s\n", date_iso8601(0), data2);
90 fflush(logfile);
91 }
92 }

Properties

Name Value
svn:eol-style native
svn:keywords Id

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28