~ubuntu-branches/ubuntu/precise/netatalk/precise

« back to all changes in this revision

Viewing changes to include/atalk/logger.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Rittau
  • Date: 2004-01-19 12:43:49 UTC
  • Revision ID: james.westby@ubuntu.com-20040119124349-es563jbp0hk0ae51
Tags: upstream-1.6.4
ImportĀ upstreamĀ versionĀ 1.6.4

Show diffs side-by-side

added added

removed removed

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