1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*
* $Id$
*
* Copyright (c) 1994, 1995. Netscape Communications Corporation. All
* rights reserved.
*
* Use of this software is governed by the terms of the license agreement for
* the Netscape Communications or Netscape Comemrce Server between the
* parties.
*/
/* ------------------------------------------------------------------------ */
/*
* ereport.h: Records transactions, reports errors to administrators, etc.
*
* Rob McCool
*/
#ifndef EREPORT_H
#define EREPORT_H
#include "../base/session.h" /* Session structure */
#ifdef XP_UNIX
#include <pwd.h> /* struct passwd */
#endif /* XP_UNIX */
/* ------------------------------ Constants ------------------------------- */
/*
* The maximum length of an error message. NOT RUN-TIME CHECKED
*/
#define MAX_ERROR_LEN 8192
/* A warning is a minor mishap, such as a 404 being issued. */
#define LOG_WARN 0
/*
* A misconfig is when there is a syntax error or permission violation in
* a config. file.
*/
#define LOG_MISCONFIG 1
/*
* Security warnings are issued when authentication fails, or a host is
* given a 403 return code.
*/
#define LOG_SECURITY 2
/*
* A failure is when a request could not be fulfilled due to an internal
* problem, such as a CGI script exiting prematurely, or a filesystem
* permissions problem.
*/
#define LOG_FAILURE 3
/*
* A catastrophe is a fatal server error such as running out of
* memory or processes, or a system call failing, or even a server crash.
* The server child cannot recover from a catastrophe.
*/
#define LOG_CATASTROPHE 4
/*
* Informational message, of no concern.
*/
#define LOG_INFORM 5
/*
* The time format to use in the error log
*/
#define ERR_TIMEFMT "[%d/%b/%Y:%H:%M:%S]"
/* The fd you will get if you are reporting errors to SYSLOG */
#define ERRORS_TO_SYSLOG -1
/* ------------------------------ Prototypes ------------------------------ */
/*
* ereport logs an error of the given degree and formats the arguments with
* the printf() style fmt. Returns whether the log was successful. Records
* the current date.
*/
int ereport(int degree, char *fmt, ...);
/*
* ereport_init initializes the error logging subsystem and opens the static
* file descriptors. It returns NULL upon success and an error string upon
* error. If a userpw is given, the logs will be chowned to that user.
*
* email is the address of a person to mail upon catastrophic error. It
* can be NULL if no e-mail is desired. ereport_init will not duplicate
* its own copy of this string; you must make sure it stays around and free
* it when you shut down the server.
*/
char *ereport_init(char *err_fn, char *email, struct passwd *pw);
/*
* log_terminate closes the error and common log file descriptors.
*/
void ereport_terminate(void);
/* For restarts */
SYS_FILE ereport_getfd(void);
#endif
|