]> arthur.barton.de Git - netatalk.git/blob - include/atalk/logger.h
changed the layout to fit in a standard width window
[netatalk.git] / include / atalk / logger.h
1
2 #ifndef _ATALK_LOGGER_H
3 #define _ATALK_LOGGER_H 1
4
5 #include <atalk/boolean.h>
6
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
10
11 #define MAXLOGSIZE 512
12
13 enum loglevels {
14   log_severe   = 0,
15   log_error    = 10,
16   log_warning  = 20,
17   log_note     = 30,
18   log_info     = 40,
19   log_debug    = 50
20 };
21 #define LOGLEVEL_STRING_IDENTIFIERS { \
22   "LOG_SEVERE",                       \
23   "LOG_ERROR",                        \
24   "LOG_WARN",                         \
25   "LOG_NOTE",                         \
26   "LOG_INFO",                         \
27   "LOG_DEBUG"}                        
28
29 /* this is the enum specifying all availiable logtypes */
30 enum logtypes {
31   logtype_default,
32   logtype_core,
33   logtype_logger,
34   logtype_cnid,
35   logtype_afpd,
36
37   logtype_end_of_list_marker  /* don't put any logtypes after this */
38 };
39
40 /* these are the string identifiers corresponding to each logtype */
41 #define LOGTYPE_STRING_IDENTIFIERS { \
42   "Default",                         \
43   "Core",                            \
44   "Logger",                          \
45   "CNID",                            \
46   "AFPDaemon",                       \
47                                      \
48   "end_of_list_marker"}              \
49
50 /* Display Option flags. */
51 /* redefine these so they can don't interfeer with syslog */
52 /* these can be used in standard logging too */
53 #define logoption_pid         0x01   /* log the pid with each message */
54 #define logoption_cons        0x02   /* log on the console if error logging */
55 #define logoption_ndelay      0x08   /* don't delay open */
56 #define logoption_perror      0x20   /* log to stderr as well */
57 #define logoption_nfile       0x40   /* ignore the file that called the log */
58 #define logoption_nline       0x80   /* ignore the line that called the log*/
59
60 /* facility codes */
61 /* redefine these so they can don't interfeer with syslog */
62 #define logfacility_user        (1<<3)  /* random user-level messages */
63 #define logfacility_mail        (2<<3)  /* mail system */
64 #define logfacility_daemon      (3<<3)  /* system daemons */
65 #define logfacility_auth        (4<<3)  /* security/authorization messages */
66 #define logfacility_syslog      (5<<3)  /* messages generated by syslogd */
67 #define logfacility_lpr         (6<<3)  /* line printer subsystem */
68 #define logfacility_authpriv    (10<<3) /* security/auth messages (private) */
69 #define logfacility_ftp         (11<<3) /* ftp daemon */
70
71 /* Setup the log filename and the loglevel, and the type of log it is. */
72 /* setup the internal variables used by the logger (called automatically) */
73 void log_init();
74
75 bool log_setup(char *filename, enum loglevels loglevel, enum logtypes logtype, 
76                int display_options);
77
78 /* Setup the Level and type of log that will be logged to syslog. */
79 void syslog_setup(enum loglevels loglevel, enum logtypes logtype, 
80                   int display_options, int facility);
81
82 void setuplog(char *logsource, char *logtype, char *loglevel, char *filename);
83
84 /* finish up and close the logs */
85 void log_close();
86
87 /* This function sets up the ProcessName */
88 void set_processname(char *processname);
89
90 /* Log a Message */
91 void make_log_entry(enum loglevels loglevel, enum logtypes logtype, 
92              char *message, ...);
93
94 #ifndef DISABLE_LOGGER
95 typedef void(*make_log_func)
96        (enum loglevels loglevel, enum logtypes logtype, char *message, ...);
97 make_log_func set_log_location(char *srcfilename, int srclinenumber);
98
99 void LoadProccessNameFromProc();
100
101 #define LOG set_log_location(__FILE__, __LINE__)
102 #else /* DISABLE_LOGGER */
103 /* if the logger is disabled the rest is a bit futile */
104 #define LOG make_log_entry
105 #endif /* DISABLE_LOGGER */
106
107 #endif