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