ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/logger.h
Revision: 1.1
Committed: Sun Sep 9 20:05:51 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
- changed configurations to the c++ stdlib
- more #defines to enum
- removed getopt.h and link.h from the system as they were unused
- reworked logstreams
- added an itoa with old syntax
- made klines objects
- moved some global variables into appropriate classes
- fixed boost.foreach's compiler workaround #if's
- allow other files to add exceptions with ADD_EXCEPTION
- changed mynick_t to c++ object
- moved servers.h out of atheme.h
- corrected PING from inspircd 1.2

File Contents

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