]> jfr.im git - irc/evilnet/x3.git/blob - src/log.h
this never ends...
[irc/evilnet/x3.git] / src / log.h
1 /* log.h - Diagnostic and error logging
2 * Copyright 2000-2003 srvx Development Team
3 *
4 * This file is part of x3.
5 *
6 * srvx is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 */
20
21 #ifndef LOG_H
22 #define LOG_H
23
24 #include "common.h"
25
26 enum log_severity {
27 LOG_REPLAY, /* 0 */
28 LOG_DEBUG,
29 LOG_COMMAND,
30 LOG_INFO,
31 LOG_OVERRIDE,
32 LOG_STAFF, /* 5 */
33 LOG_WARNING,
34 LOG_ERROR,
35 LOG_FATAL,
36 LOG_NUM_SEVERITIES
37 };
38
39 struct log_type;
40
41 void log_init(void);
42 void log_reopen(void);
43 void log_debug(void);
44
45 /* bitmap values in flags parameter to log_audit */
46 #define AUDIT_HOSTMASK 0x01
47
48 struct log_type *log_register_type(const char *name, const char *default_log);
49 /* constraint for log_audit: sev one of LOG_COMMAND, LOG_OVERRIDE, LOG_STAFF */
50 void log_audit(struct log_type *type, enum log_severity sev, struct userNode *user, struct userNode *bot, const char *channel_name, unsigned int flags, const char *command);
51 /* constraint for log_module: sev < LOG_COMMAND */
52 void log_module(struct log_type *type, enum log_severity sev, const char *format, ...) PRINTF_LIKE(3, 4);
53 void log_replay(struct log_type *type, int is_write, const char *line);
54
55 /* Log searching functions - ONLY searches log_audit'ed data */
56
57 struct logEntry
58 {
59 /* field nullable in real entries? */
60 time_t time;
61 enum log_severity slvl;
62 struct userNode *bot; /* no */
63 char *channel_name; /* yes */
64 char *user_nick; /* no */
65 char *user_account; /* yes */
66 char *user_hostmask; /* yes */
67 char *command; /* no */
68 char *default_desc;
69 struct logEntry *next;
70 struct logEntry *prev;
71 };
72
73 struct logSearch
74 {
75 struct logEntry masks;
76 struct log_type *type;
77 time_t min_time;
78 time_t max_time;
79 unsigned int limit;
80 unsigned int severities;
81 };
82
83 struct logReport
84 {
85 struct userNode *reporter;
86 struct userNode *user;
87 };
88
89 typedef void (*entry_search_func)(struct logEntry *match, void *extra);
90 void log_report_entry(struct logEntry *match, void *extra);
91 struct logSearch* log_discrim_create(struct userNode *service, struct userNode *user, unsigned int argc, char *argv[]);
92 unsigned int log_entry_search(struct logSearch *discrim, entry_search_func esf, void *data);
93 void report_entry(struct userNode *service, struct userNode *user, struct logEntry *entry);
94 void SyncLog(char *fmt,...);
95
96 #endif