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