]>
Commit | Line | Data |
---|---|---|
1 | /* log.h - Diagnostic and error logging | |
2 | * Copyright 2000-2003 srvx Development Team | |
3 | * | |
4 | * This file is part of x3. | |
5 | * | |
6 | * x3 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 3 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 | #define AccountingLog "everything.log" | |
27 | ||
28 | enum log_severity { | |
29 | LOG_REPLAY, /* 0 */ | |
30 | LOG_DEBUG, | |
31 | LOG_COMMAND, | |
32 | LOG_INFO, | |
33 | LOG_OVERRIDE, | |
34 | LOG_STAFF, /* 5 */ | |
35 | LOG_WARNING, | |
36 | LOG_ERROR, | |
37 | LOG_FATAL, | |
38 | LOG_NUM_SEVERITIES | |
39 | }; | |
40 | ||
41 | struct log_type; | |
42 | ||
43 | void log_init(void); | |
44 | void log_reopen(void); | |
45 | void log_debug(void); | |
46 | ||
47 | /* bitmap values in flags parameter to log_audit */ | |
48 | #define AUDIT_HOSTMASK 0x01 | |
49 | ||
50 | struct log_type *log_register_type(const char *name, const char *default_log); | |
51 | /* constraint for log_audit: sev one of LOG_COMMAND, LOG_OVERRIDE, LOG_STAFF */ | |
52 | 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); | |
53 | /* constraint for log_module: sev < LOG_COMMAND */ | |
54 | void log_module(struct log_type *type, enum log_severity sev, const char *format, ...) PRINTF_LIKE(3, 4); | |
55 | void log_replay(struct log_type *type, int is_write, const char *line); | |
56 | ||
57 | /* Log searching functions - ONLY searches log_audit'ed data */ | |
58 | ||
59 | struct logEntry | |
60 | { | |
61 | /* field nullable in real entries? */ | |
62 | time_t time; | |
63 | enum log_severity slvl; | |
64 | struct userNode *bot; /* no */ | |
65 | char *channel_name; /* yes */ | |
66 | char *user_nick; /* no */ | |
67 | char *user_account; /* yes */ | |
68 | char *user_hostmask; /* yes */ | |
69 | char *command; /* no */ | |
70 | char *default_desc; | |
71 | struct logEntry *next; | |
72 | struct logEntry *prev; | |
73 | }; | |
74 | ||
75 | struct logSearch | |
76 | { | |
77 | struct logEntry masks; | |
78 | struct log_type *type; | |
79 | time_t min_time; | |
80 | time_t max_time; | |
81 | unsigned int limit; | |
82 | unsigned int severities; | |
83 | }; | |
84 | ||
85 | struct logReport | |
86 | { | |
87 | struct userNode *reporter; | |
88 | struct userNode *user; | |
89 | }; | |
90 | ||
91 | typedef void (*entry_search_func)(struct logEntry *match, void *extra); | |
92 | void log_report_entry(struct logEntry *match, void *extra); | |
93 | struct logSearch* log_discrim_create(struct userNode *service, struct userNode *user, unsigned int argc, char *argv[]); | |
94 | unsigned int log_entry_search(struct logSearch *discrim, entry_search_func esf, void *data); | |
95 | void report_entry(struct userNode *service, struct userNode *user, struct logEntry *entry); | |
96 | void SyncLog(char *fmt,...); | |
97 | int ShowLog(struct userNode *user, struct chanNode *cptr, char *chan, char *nuh, char *command, char *rest, int maxlines); | |
98 | ||
99 | #endif |