]> jfr.im git - irc/evilnet/x3.git/blame - src/log.h
Minor typo in previous commit where returning 0 when it should have been 1 from opser...
[irc/evilnet/x3.git] / src / log.h
CommitLineData
d76ed9a9 1/* log.h - Diagnostic and error logging
2 * Copyright 2000-2003 srvx Development Team
3 *
83ff05c3 4 * This file is part of x3.
d76ed9a9 5 *
d0f04f71 6 * x3 is free software; you can redistribute it and/or modify
d76ed9a9 7 * it under the terms of the GNU General Public License as published by
348683aa 8 * the Free Software Foundation; either version 3 of the License, or
d76ed9a9 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
23475fc6 26#define AccountingLog "everything.log"
27
d76ed9a9 28enum 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
41struct log_type;
42
43void log_init(void);
44void log_reopen(void);
45void log_debug(void);
46
47/* bitmap values in flags parameter to log_audit */
48#define AUDIT_HOSTMASK 0x01
49
50struct 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 */
52void 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 */
54void log_module(struct log_type *type, enum log_severity sev, const char *format, ...) PRINTF_LIKE(3, 4);
55void log_replay(struct log_type *type, int is_write, const char *line);
56
57/* Log searching functions - ONLY searches log_audit'ed data */
58
59struct 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
75struct 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
85struct logReport
86{
87 struct userNode *reporter;
88 struct userNode *user;
89};
90
91typedef void (*entry_search_func)(struct logEntry *match, void *extra);
92void log_report_entry(struct logEntry *match, void *extra);
93struct logSearch* log_discrim_create(struct userNode *service, struct userNode *user, unsigned int argc, char *argv[]);
94unsigned int log_entry_search(struct logSearch *discrim, entry_search_func esf, void *data);
95void report_entry(struct userNode *service, struct userNode *user, struct logEntry *entry);
eb5d6b73 96void SyncLog(char *fmt,...);
23475fc6 97int ShowLog(struct userNode *user, struct chanNode *cptr, char *chan, char *nuh, char *command, char *rest, int maxlines);
d76ed9a9 98
99#endif