src/server/ereport.h

changeset 1
3c066d52342d
equal deleted inserted replaced
0:4c89c7683fb6 1:3c066d52342d
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5 *
6 * THE BSD LICENSE
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * Redistributions of source code must retain the above copyright notice, this
12 * list of conditions and the following disclaimer.
13 * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 *
17 * Neither the name of the nor the names of its contributors may be
18 * used to endorse or promote products derived from this software without
19 * specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
25 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef BASE_EREPORT_H
35 #define BASE_EREPORT_H
36
37 #ifndef NOINTNSAPI
38 #define INTNSAPI
39 #endif /* !NOINTNSAPI */
40
41 /*
42 * ereport.h: Records transactions, reports errors to administrators, etc.
43 *
44 * Rob McCool
45 */
46
47 #ifndef BASE_SESSION_H
48 #include "session.h"
49 #endif /* !BASE_SESSION_H */
50
51 /* Pseudo-filename to enable logging to syslog */
52 #define EREPORT_SYSLOG "SYSLOG"
53
54 /* NSAPI degrees used by Java but not exposed in nsapi.h */
55 #define LOG_FINER 7
56 #define LOG_FINEST 8
57
58 /* --- Begin function prototypes --- */
59
60 #ifdef INTNSAPI
61
62 NSPR_BEGIN_EXTERN_C
63
64 /*
65 * INTereport logs an error of the given degree and formats the arguments with
66 * the printf() style fmt. Returns whether the log was successful. Records
67 * the current date.
68 */
69
70 NSAPI_PUBLIC int INTereport(int degree, const char *fmt, ...);
71 NSAPI_PUBLIC int INTereport_v(int degree, const char *fmt, va_list args);
72
73 /*
74 * INTereport_init initializes the error logging subsystem and opens the static
75 * file descriptors. It returns NULL upon success and an error string upon
76 * error. If a userpw is given, the logs will be chowned to that user.
77 */
78
79 NSAPI_PUBLIC
80 char *INTereport_init(const char *err_fn, const char *email, struct passwd *pwuser, const char *version, int restarted);
81
82 NSAPI_PUBLIC void INTereport_terminate(void);
83
84 /* For restarts */
85 NSAPI_PUBLIC SYS_FILE INTereport_getfd(void);
86
87 NSPR_END_EXTERN_C
88
89 #ifdef __cplusplus
90 class EreportableException;
91 NSAPI_PUBLIC int INTereport_exception(const EreportableException& e);
92 #endif
93
94 /* --- End function prototypes --- */
95
96 #define ereport INTereport
97 #define ereport_v INTereport_v
98 #define ereport_init INTereport_init
99 #define ereport_terminate INTereport_terminate
100 #define ereport_getfd INTereport_getfd
101 #define ereport_exception INTereport_exception
102
103 typedef int (EreportFunc)(const VirtualServer* vs, int degree, const char *formatted, int formattedlen, const char *raw, int rawlen, void *data);
104
105 void ereport_set_servername(const char* name);
106 void ereport_set_logvsid(PRBool b);
107 void ereport_set_logall(PRBool b);
108 void ereport_set_alwaysreopen(PRBool b);
109 void ereport_set_timefmt(const char* timeFmt);
110 void ereport_set_degree(int degree);
111 int ereport_level2degree(const char *level, int defdegree);
112 PRBool ereport_can_log(int degree);
113 int ereport_request(Request* rq, int degree, const char *fmt, ...);
114 char *ereport_abs_filename(const char *filename);
115 void ereport_rotate(const char* ext);
116 void ereport_set_rotate_callback(void (*fn)(const char* filenameNew, const char* filenameOld));
117 void ereport_reopen(void);
118 void ereport_outofmemory(void);
119 void ereport_disaster(int degree, const char *fmt, ...);
120 NSAPI_PUBLIC int ereport_register_cb(EreportFunc* ereport_func, void* data);
121 NSAPI_PUBLIC int ereport_register_thread_cb(EreportFunc* ereport_func, void* data);
122
123 #endif /* INTNSAPI */
124
125 #endif /* !BASE_EREPORT_H */

mercurial