2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
11 /* ------------------------------------------------------------------------ */
15 * ereport.h: Records transactions, reports errors to administrators, etc.
25 #include "../base/session.h" /* Session structure */
27 #include <pwd.h> /* struct passwd */
31 /* ------------------------------ Constants ------------------------------- */
35 * The maximum length of an error message. NOT RUN-TIME CHECKED
38 #define MAX_ERROR_LEN 8192
40 /* A warning is a minor mishap, such as a 404 being issued. */
44 * A misconfig is when there is a syntax error or permission violation in
47 #define LOG_MISCONFIG 1
50 * Security warnings are issued when authentication fails, or a host is
51 * given a 403 return code.
53 #define LOG_SECURITY 2
56 * A failure is when a request could not be fulfilled due to an internal
57 * problem, such as a CGI script exiting prematurely, or a filesystem
58 * permissions problem.
63 * A catastrophe is a fatal server error such as running out of
64 * memory or processes, or a system call failing, or even a server crash.
65 * The server child cannot recover from a catastrophe.
67 #define LOG_CATASTROPHE 4
70 * Informational message, of no concern.
75 * The time format to use in the error log
78 #define ERR_TIMEFMT "[%d/%b/%Y:%H:%M:%S]"
81 /* The fd you will get if you are reporting errors to SYSLOG */
83 #define ERRORS_TO_SYSLOG -1
86 /* ------------------------------ Prototypes ------------------------------ */
90 * ereport logs an error of the given degree and formats the arguments with
91 * the printf() style fmt. Returns whether the log was successful. Records
95 int ereport(int degree
, char *fmt
, ...);
98 * ereport_init initializes the error logging subsystem and opens the static
99 * file descriptors. It returns NULL upon success and an error string upon
100 * error. If a userpw is given, the logs will be chowned to that user.
102 * email is the address of a person to mail upon catastrophic error. It
103 * can be NULL if no e-mail is desired. ereport_init will not duplicate
104 * its own copy of this string; you must make sure it stays around and free
105 * it when you shut down the server.
108 char *ereport_init(char *err_fn
, char *email
, struct passwd
*pw
);
111 * log_terminate closes the error and common log file descriptors.
113 void ereport_terminate();
116 SYS_FILE
ereport_getfd();