src/server/util/ereport.h

changeset 29
e8619defde14
parent 28
f387669912e8
child 30
27c7511c0e34
equal deleted inserted replaced
28:f387669912e8 29:e8619defde14
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 //TODO: include netsite.h or systems.h
48
49 #ifndef BASE_SESSION_H
50 #include "../daemon/session.h"
51 #endif /* !BASE_SESSION_H */
52
53 /* Pseudo-filename to enable logging to syslog */
54 #define EREPORT_SYSLOG "SYSLOG"
55
56 /* NSAPI degrees used by Java but not exposed in nsapi.h */
57 #define LOG_FINER 7
58 #define LOG_FINEST 8
59
60 /* --- Begin function prototypes --- */
61
62 #ifdef INTNSAPI
63
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67
68 /*
69 * INTereport logs an error of the given degree and formats the arguments with
70 * the printf() style fmt. Returns whether the log was successful. Records
71 * the current date.
72 */
73
74 NSAPI_PUBLIC int INTereport(int degree, const char *fmt, ...);
75 NSAPI_PUBLIC int INTereport_v(int degree, const char *fmt, va_list args);
76
77 /*
78 * INTereport_init initializes the error logging subsystem and opens the static
79 * file descriptors. It returns NULL upon success and an error string upon
80 * error. If a userpw is given, the logs will be chowned to that user.
81 */
82
83 NSAPI_PUBLIC
84 char *INTereport_init(const char *err_fn, const char *email, struct passwd *pwuser, const char *version, int restarted);
85
86 NSAPI_PUBLIC void INTereport_terminate(void);
87
88 /* For restarts */
89 NSAPI_PUBLIC SYS_FILE INTereport_getfd(void);
90
91 #ifdef __cplusplus
92 }
93 #endif
94
95 #ifdef __cplusplus
96 class EreportableException;
97 NSAPI_PUBLIC int INTereport_exception(const EreportableException& e);
98 #endif
99
100 /* --- End function prototypes --- */
101
102 #define ereport INTereport
103 #define ereport_v INTereport_v
104 #define ereport_init INTereport_init
105 #define ereport_terminate INTereport_terminate
106 #define ereport_getfd INTereport_getfd
107 #define ereport_exception INTereport_exception
108
109 typedef int (EreportFunc)(const VirtualServer* vs, int degree, const char *formatted, int formattedlen, const char *raw, int rawlen, void *data);
110
111 void ereport_set_servername(const char* name);
112 void ereport_set_logvsid(PRBool b);
113 void ereport_set_logall(PRBool b);
114 void ereport_set_alwaysreopen(PRBool b);
115 void ereport_set_timefmt(const char* timeFmt);
116 void ereport_set_degree(int degree);
117 int ereport_level2degree(const char *level, int defdegree);
118 PRBool ereport_can_log(int degree);
119 int ereport_request(Request* rq, int degree, const char *fmt, ...);
120 char *ereport_abs_filename(const char *filename);
121 void ereport_rotate(const char* ext);
122 void ereport_set_rotate_callback(void (*fn)(const char* filenameNew, const char* filenameOld));
123 void ereport_reopen(void);
124 void ereport_outofmemory(void);
125 void ereport_disaster(int degree, const char *fmt, ...);
126 NSAPI_PUBLIC int ereport_register_cb(EreportFunc* ereport_func, void* data);
127 NSAPI_PUBLIC int ereport_register_thread_cb(EreportFunc* ereport_func, void* data);
128
129 #endif /* INTNSAPI */
130
131 #endif /* !BASE_EREPORT_H */

mercurial