1 karl 1.24 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.8 //
|
3 karl 1.18 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.17 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.18 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.20 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.24 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.8 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.10 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.8 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.24 //
|
21 kumpf 1.10 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.8 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.10 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.8 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_Logger_h
35 #define Pegasus_Logger_h
36
37 #include <Pegasus/Common/Config.h>
38 #include <Pegasus/Common/Formatter.h>
|
39 kumpf 1.11 #include <Pegasus/Common/Linkage.h>
|
40 david 1.14 #include <Pegasus/Common/System.h>
|
41 mike 1.21 #include <Pegasus/Common/MessageLoader.h>
42
|
43 mike 1.8 PEGASUS_NAMESPACE_BEGIN
44
45 class LoggerRep;
46
|
47 mike 1.21 /** This class provides the interface for writing log records to the log.
|
48 mike 1.8 */
49 class PEGASUS_COMMON_LINKAGE Logger
50 {
51 public:
52
|
53 david.dillard 1.22 enum LogFileType
|
54 mike 1.21 {
|
55 david.dillard 1.22 TRACE_LOG,
56 STANDARD_LOG,
|
57 kumpf 1.30 AUDIT_LOG, // Use only if PEGASUS_ENABLE_AUDIT_LOGGER is defined
|
58 marek 1.32 ERROR_LOG
|
59 mike 1.8 };
|
60 mike 1.21
|
61 marek 1.32 enum { NUM_LOGS = 4 };
|
62 david.dillard 1.22
63 /** Log file Level - Defines the loglevel of the log entry irrespective of
64 which log file it goes into. This is actually a bit mask as defined in
65 logger.cpp. Thus, it serves both as a level of indication of the
66 seriousness and possibly as a mask to select what is logged.
|
67 mike 1.8 ATTN: The selection test has not been done.
68 */
69 static const Uint32 TRACE;
70 static const Uint32 INFORMATION;
71 static const Uint32 WARNING;
72 static const Uint32 SEVERE;
73 static const Uint32 FATAL;
74
|
75 mike 1.21 /** Puts a message to the defined log file
76 @param logFileType - Type of log file (Trace, etc.)
|
77 david.dillard 1.22 @param systemId - ID of the system generating the log entry within
|
78 mike 1.21 Pegasus. This is user defined but generally breaks down into major
79 Pegasus components.
80 @param level logLevel of the log entry. To be used both t0
|
81 david.dillard 1.22 mark the log entry and tested against a mask to determine if log
|
82 mike 1.21 entry should be written.
|
83 david.dillard 1.22 @param formatString Format definition string for the Log. See the
|
84 mike 1.21 Formatter for details.
85 @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
86 that go into the log entry.
87 <pre>
|
88 kumpf 1.26 Logger::put(Logger::TRACE_LOG, System::CIMSERVER, Logger::WARNING,
|
89 mike 1.21 "X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5);
90 </pre>
91 */
92 static void put(
93 LogFileType logFileType,
94 const String& systemId,
95 Uint32 logLevel,
96 const String& formatString,
97 const Formatter::Arg& arg0,
98 const Formatter::Arg& arg1,
99 const Formatter::Arg& arg2,
100 const Formatter::Arg& arg3,
101 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
102 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
103 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
104 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
105 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
106 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
107
108 /** Optimized zero-argument form of put().
109 */
110 mike 1.21 static void put(
111 LogFileType logFileType,
112 const String& systemId,
113 Uint32 logLevel,
114 const String& formatString);
|
115 david 1.12
|
116 mike 1.21 /** Optimized one-argument form of put().
|
117 mike 1.8 */
118 static void put(
|
119 mike 1.21 LogFileType logFileType,
120 const String& systemId,
121 Uint32 logLevel,
122 const String& formatString,
123 const Formatter::Arg& arg0);
|
124 karl 1.19
|
125 mike 1.21 /** Optimized two-argument form of put().
126 */
|
127 karl 1.19 static void put(
|
128 mike 1.21 LogFileType logFileType,
129 const String& systemId,
130 Uint32 logLevel,
131 const String& formatString,
132 const Formatter::Arg& arg0,
133 const Formatter::Arg& arg1);
|
134 karl 1.19
|
135 mike 1.21 /** Optimized three-argument form of put().
136 */
|
137 karl 1.19 static void put(
|
138 mike 1.21 LogFileType logFileType,
139 const String& systemId,
140 Uint32 logLevel,
141 const String& formatString,
142 const Formatter::Arg& arg0,
143 const Formatter::Arg& arg1,
144 const Formatter::Arg& arg2);
|
145 david 1.12
|
146 chuck 1.15 /** put_l - Puts a localized message to the defined log file
|
147 mike 1.21 @param logFileType - Type of log file (Trace, etc.)
|
148 david.dillard 1.22 @param systemId - ID of the system generating the log entry within
|
149 mike 1.21 Pegasus. This is user defined but generally breaks down into major
150 Pegasus components.
151 @param level logLevel of the log entry. To be used both t0
|
152 david.dillard 1.22 mark the log entry and tested against a mask to determine if log
|
153 mike 1.21 entry should be written.
|
154 david.dillard 1.22 @param messageId Message ID of the format string to load from
155 the resource bundle.
156 @param formatString Default format definition string. See the
|
157 mike 1.21 Formatter for details. This will be used as the default format string
158 in case the resource bundle cannot be found.
159 @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
160 that go into the log entry.
161 <pre>
|
162 kumpf 1.26 Logger::put(Logger::TRACE_LOG, System::CIMSERVER, Logger::WARNING,
|
163 mike 1.21 "X=$0, Y=$1, Z=$2", 88, "Hello World", 7.5);
164 </pre>
|
165 chuck 1.15 */
166 static void put_l(
|
167 mike 1.21 LogFileType logFileType,
168 const String& systemId,
169 Uint32 logLevel,
|
170 kumpf 1.34 const char* messageId,
171 const char* formatString,
|
172 mike 1.21 const Formatter::Arg& arg0,
173 const Formatter::Arg& arg1,
174 const Formatter::Arg& arg2,
175 const Formatter::Arg& arg3,
176 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
177 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
178 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
179 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
180 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
181 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
182 karl 1.19
|
183 mike 1.21 /** Optimized zero-argument form of put_l().
184 */
185 static void put_l(
186 LogFileType logFileType,
187 const String& systemId,
188 Uint32 logLevel,
|
189 kumpf 1.34 const char* messageId,
190 const char* formatString);
|
191 mike 1.21
192 /** Optimized one-argument form of put_l().
193 */
194 static void put_l(
195 LogFileType logFileType,
196 const String& systemId,
197 Uint32 logLevel,
|
198 kumpf 1.34 const char* messageId,
199 const char* formatString,
|
200 mike 1.21 const Formatter::Arg& arg0);
201
202 /** Optimized two-argument form of put_l().
203 */
|
204 karl 1.19 static void put_l(
|
205 mike 1.21 LogFileType logFileType,
206 const String& systemId,
207 Uint32 logLevel,
|
208 kumpf 1.34 const char* messageId,
209 const char* formatString,
|
210 mike 1.21 const Formatter::Arg& arg0,
211 const Formatter::Arg& arg1);
|
212 karl 1.19
|
213 mike 1.21 /** Optimized three-argument form of put_l().
214 */
|
215 karl 1.19 static void put_l(
|
216 mike 1.21 LogFileType logFileType,
217 const String& systemId,
218 Uint32 logLevel,
|
219 kumpf 1.34 const char* messageId,
220 const char* formatString,
|
221 mike 1.21 const Formatter::Arg& arg0,
222 const Formatter::Arg& arg1,
223 const Formatter::Arg& arg2);
|
224 chuck 1.15
|
225 kumpf 1.35 /** Puts a trace message into the specified log.
|
226 mike 1.21 */
|
227 david 1.12 static void trace(
|
228 mike 1.21 LogFileType logFileType,
229 const String& systemId,
230 const Uint32 logComponent,
|
231 kumpf 1.35 const String& message);
|
232 mike 1.21
|
233 mike 1.8 /** setHomeDirectory
234 */
235 static void setHomeDirectory(const String& homeDirectory);
236
|
237 david 1.12 /** setlogLevelMask
|
238 mike 1.8 */
|
239 david 1.12 static void setlogLevelMask(const String logLevelList);
|
240 mike 1.8
|
241 mike 1.21 /** Returns true if the given string is one of the legal log levels.
242 */
|
243 david 1.12 static Boolean isValidlogLevel(const String logLevel);
|
244 mike 1.21
245 /** Tests if a log entry would be created by this call before
246 the logger is called. This function is intended to be used
247 within the server for high usage log entries to avoid the
248 overhead of doing the call when no log is created.
249 @param logLevel Uint32 defining the level of the log to be
250 executed.
251 <p><b>Example:</b>
252 <pre>
253 if (Logger::wouldLog(Logger::TRACE))
254 {
|
255 david.dillard 1.22 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
|
256 mike 1.21 Logger::TRACE, "HTTPMessage - HTTP header name: $0 "
257 "HTTP header value: $1" ,name,value);
258 }
259 </pre>
260 */
|
261 david.dillard 1.22 static Boolean wouldLog(Uint32 logLevel)
|
262 mike 1.21 {
|
263 david.dillard 1.22 return (_severityMask & logLevel) != 0;
|
264 mike 1.21 }
265
|
266 mike 1.8 private:
267
268 static LoggerRep* _rep;
269 static String _homeDirectory;
270 static Uint32 _severityMask;
|
271 david 1.12
272 static const Uint32 _NUM_LOGLEVEL;
273
274 static void _putInternal(
|
275 mike 1.21 LogFileType logFileType,
276 const String& systemId,
277 const Uint32 logComponent,
278 Uint32 logLevel,
279 const String& formatString,
|
280 kumpf 1.34 const char* messageId,
|
281 mike 1.21 const Formatter::Arg& arg0 = Formatter::DEFAULT_ARG,
282 const Formatter::Arg& arg1 = Formatter::DEFAULT_ARG,
283 const Formatter::Arg& arg2 = Formatter::DEFAULT_ARG,
284 const Formatter::Arg& arg3 = Formatter::DEFAULT_ARG,
285 const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
286 const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
287 const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
288 const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
289 const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
290 const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
|
291 mike 1.8 };
292
293 PEGASUS_NAMESPACE_END
294
295 #endif /* Pegasus_Logger_h */
|