ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/logger.h
Revision: 1.2
Committed: Sun Sep 16 18:54:42 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +10 -5 lines
Log Message:
#defines to enum

File Contents

# User Rev Content
1 pippijn 1.2 /**
2     * logger.h: Logstreams
3 pippijn 1.1 *
4 pippijn 1.2 * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
5     * Rights to this code are as documented in COPYING.
6 pippijn 1.1 *
7 pippijn 1.2 *
8     * Portions of this file were derived from sources bearing the following license:
9     * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
10     * Rights to this code are as documented in doc/pod/gplicense.pod.
11     *
12     * $Id: logger.h,v 1.1 2007-09-09 20:05:51 pippijn Exp $
13 pippijn 1.1 */
14    
15     #ifndef LOGGER_H
16     #define LOGGER_H
17    
18     #include <object.h>
19    
20     /* logger.c */
21     struct logfile_t : object, zero_initialised
22     {
23     unsigned index;
24    
25     void *log_file; /* opaque: can either be mychan_t or FILE --nenolod */
26     char *log_path;
27     unsigned int log_mask;
28    
29     public: // methods
30     static logfile_t *create (char const * const log_path_, unsigned int log_mask);
31     virtual void write (char const * const buf);
32     void enter (); // XXX: naming?
33     void leave ();
34    
35     private:
36     virtual void _destroy ();
37     };
38    
39     E char *log_path; /* contains path to default log. */
40     E int log_force;
41    
42     enum loglevel
43     {
44     /* general */
45     LG_NONE = 1 << 0, /* don't log */
46     LG_INFO = 1 << 1, /* log general info */
47     LG_ERROR = 1 << 2, /* log real important stuff */
48     LG_IOERROR = 1 << 3, /* log I/O errors. */
49     LG_DEBUG = 1 << 4, /* log debugging stuff */
50     /* commands */
51     LG_CMD_ADMIN = 1 << 5, /* oper-only commands */
52     LG_CMD_REGISTER = 1 << 6, /* register/drop */
53     LG_CMD_SET = 1 << 7, /* change properties of static data */
54     LG_CMD_DO = 1 << 8, /* change properties of dynamic data */
55     LG_CMD_LOGIN = 1 << 9, /* login/logout */
56     LG_CMD_GET = 1 << 10, /* query information */
57     /* other */
58     LG_NETWORK = 1 << 11, /* netsplit/netjoin */
59     LG_WALLOPS = 1 << 12, /* NOTYET wallops from opers/other servers */
60     LG_RAWDATA = 1 << 13, /* all data sent/received */
61     LG_REGISTER = 1 << 14, /* all registration related messages */
62     LG_WARN1 = 1 << 15, /* NOTYET messages formerly walloped */
63     LG_WARN2 = 1 << 16, /* NOTYET messages formerly snooped */
64    
65     LG_CMD_ALL = LG_CMD_ADMIN | LG_CMD_REGISTER | LG_CMD_SET | LG_CMD_DO | LG_CMD_LOGIN | LG_CMD_GET,
66     LG_ALL = 1 << 31 - 1,/* XXX cannot use bit 31 as it would then be unequal to TOKEN_UNMATCHED */
67    
68     /* aliases for use with logcommand() */
69     CMDLOG_ADMIN = LG_CMD_ADMIN,
70     CMDLOG_REGISTER = LG_CMD_REGISTER | LG_REGISTER,
71     CMDLOG_SET = LG_CMD_SET,
72     CMDLOG_DO = LG_CMD_DO,
73     CMDLOG_LOGIN = LG_CMD_LOGIN,
74     CMDLOG_GET = LG_CMD_GET
75     };
76    
77     E void log_open (void);
78     E void log_shutdown (void);
79     E bool log_debug_enabled (void);
80     E void log_master_set_mask (unsigned int mask);
81     E void slog (unsigned int level, char const * const fmt, ...);
82     E void logcommand (sourceinfo_t *si, int level, char const * const fmt, ...);
83     E void logcommand_user (service_t *svs, user_t *source, int level, char const * const fmt, ...);
84     E void logcommand_external (service_t *svs, char const * const type, connection_t *source, char const * const sourcedesc, myuser_t *login, int level, char const * const fmt, ...);
85    
86     #endif