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 kumpf 1.36 @param level logLevel of the log entry. To be used both to
|
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 kumpf 1.36 @param msgParms MessageLoaderParms object containing the localizable
155 message to log.
|
156 mike 1.21 */
157 static void put_l(
158 LogFileType logFileType,
159 const String& systemId,
160 Uint32 logLevel,
|
161 kumpf 1.36 const MessageLoaderParms& msgParms);
|
162 chuck 1.15
|
163 kumpf 1.35 /** Puts a trace message into the specified log.
|
164 mike 1.21 */
|
165 david 1.12 static void trace(
|
166 mike 1.21 LogFileType logFileType,
167 const String& systemId,
168 const Uint32 logComponent,
|
169 kumpf 1.35 const String& message);
|
170 mike 1.21
|
171 mike 1.8 /** setHomeDirectory
172 */
173 static void setHomeDirectory(const String& homeDirectory);
174
|
175 david 1.12 /** setlogLevelMask
|
176 mike 1.8 */
|
177 david 1.12 static void setlogLevelMask(const String logLevelList);
|
178 mike 1.8
|
179 mike 1.21 /** Returns true if the given string is one of the legal log levels.
180 */
|
181 david 1.12 static Boolean isValidlogLevel(const String logLevel);
|
182 mike 1.21
183 /** Tests if a log entry would be created by this call before
184 the logger is called. This function is intended to be used
185 within the server for high usage log entries to avoid the
186 overhead of doing the call when no log is created.
187 @param logLevel Uint32 defining the level of the log to be
188 executed.
189 <p><b>Example:</b>
190 <pre>
191 if (Logger::wouldLog(Logger::TRACE))
192 {
|
193 david.dillard 1.22 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
|
194 mike 1.21 Logger::TRACE, "HTTPMessage - HTTP header name: $0 "
195 "HTTP header value: $1" ,name,value);
196 }
197 </pre>
198 */
|
199 david.dillard 1.22 static Boolean wouldLog(Uint32 logLevel)
|
200 mike 1.21 {
|
201 david.dillard 1.22 return (_severityMask & logLevel) != 0;
|
202 mike 1.21 }
203
|
204 mike 1.8 private:
205
206 static LoggerRep* _rep;
207 static String _homeDirectory;
208 static Uint32 _severityMask;
|
209 david 1.12
210 static const Uint32 _NUM_LOGLEVEL;
211
212 static void _putInternal(
|
213 mike 1.21 LogFileType logFileType,
214 const String& systemId,
215 const Uint32 logComponent,
216 Uint32 logLevel,
|
217 kumpf 1.36 const String& message);
|
218 mike 1.8 };
219
220 PEGASUS_NAMESPACE_END
221
222 #endif /* Pegasus_Logger_h */
|