(file) Return to Logger.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  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 kumpf 1.25 // The Logger::trace optimization introduces the PEG_LOGGER_TRACE macro which
 44            // propagates branch conditions wherever it is used.  The optimization is
 45            // disabled for C-Cover builds so the coverage of these branches is not
 46            // measured.
 47            #ifdef PEGASUS_CCOVER
 48            # define PEG_LOGGER_TRACE(ARGS_LIST) \
 49                Logger::trace ARGS_LIST
 50            #else
 51            # define PEG_LOGGER_TRACE(ARGS_LIST) \
 52 mike  1.21     do \
 53                { \
 54                    if (Logger::wouldLog(Logger::TRACE)) \
 55                    { \
 56                        Logger::trace ARGS_LIST ; \
 57                    } \
 58                } \
 59                while (0)
 60 kumpf 1.25 #endif
 61 mike  1.8  
 62            PEGASUS_NAMESPACE_BEGIN
 63            
 64            class LoggerRep;
 65            
 66 mike  1.21 /** This class provides the interface for writing log records to the log.
 67 mike  1.8  */
 68            class PEGASUS_COMMON_LINKAGE Logger
 69            {
 70            public:
 71            
 72 david.dillard 1.22     enum LogFileType
 73 mike          1.21     {
 74 david.dillard 1.22         TRACE_LOG,
 75                            STANDARD_LOG,
 76 kumpf         1.30         AUDIT_LOG, // Use only if PEGASUS_ENABLE_AUDIT_LOGGER is defined
 77 mike          1.21         ERROR_LOG,
 78                            DEBUG_LOG
 79 mike          1.8      };
 80 mike          1.21 
 81 yi.zhou       1.27     enum { NUM_LOGS = 5 };
 82 david.dillard 1.22 
 83                        /** Log file Level - Defines the loglevel of the log entry irrespective of
 84                            which log file it goes into. This is actually a bit mask as defined in
 85                            logger.cpp. Thus, it serves both as a level of indication of the
 86                            seriousness and possibly as a mask to select what is logged.
 87 mike          1.8          ATTN: The selection test has not been done.
 88                        */
 89                        static const Uint32 TRACE;
 90                        static const Uint32 INFORMATION;
 91                        static const Uint32 WARNING;
 92                        static const Uint32 SEVERE;
 93                        static const Uint32 FATAL;
 94                    
 95 mike          1.21     /** Puts a message to the defined log file
 96                            @param logFileType - Type of log file (Trace, etc.)
 97 david.dillard 1.22         @param systemId  - ID of the system generating the log entry within
 98 mike          1.21         Pegasus. This is user defined but generally breaks down into major
 99                            Pegasus components.
100                            @param level logLevel of the log entry. To be used both t0
101 david.dillard 1.22         mark the log entry and tested against a mask to determine if log
102 mike          1.21         entry should be written.
103 david.dillard 1.22         @param formatString     Format definition string for the Log. See the
104 mike          1.21         Formatter for details.
105                            @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
106                            that go into the log entry.
107                            <pre>
108 kumpf         1.26         Logger::put(Logger::TRACE_LOG, System::CIMSERVER, Logger::WARNING,
109 mike          1.21             "X=$0, Y=$1, Z=$2", 88,  "Hello World", 7.5);
110                            </pre>
111                        */
112                        static void put(
113                            LogFileType logFileType,
114                            const String& systemId,
115                            Uint32 logLevel,
116                            const String& formatString,
117                            const Formatter::Arg& arg0,
118                            const Formatter::Arg& arg1,
119                            const Formatter::Arg& arg2,
120                            const Formatter::Arg& arg3,
121                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
122                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
123                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
124                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
125                            const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
126                            const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
127                    
128                        /** Optimized zero-argument form of put().
129                        */
130 mike          1.21     static void put(
131                            LogFileType logFileType,
132                            const String& systemId,
133                            Uint32 logLevel,
134                            const String& formatString);
135 david         1.12 
136 mike          1.21     /** Optimized one-argument form of put().
137 mike          1.8      */
138                        static void put(
139 mike          1.21         LogFileType logFileType,
140                            const String& systemId,
141                            Uint32 logLevel,
142                            const String& formatString,
143                            const Formatter::Arg& arg0);
144 karl          1.19 
145 mike          1.21     /** Optimized two-argument form of put().
146                        */
147 karl          1.19     static void put(
148 mike          1.21         LogFileType logFileType,
149                            const String& systemId,
150                            Uint32 logLevel,
151                            const String& formatString,
152                            const Formatter::Arg& arg0,
153                            const Formatter::Arg& arg1);
154 karl          1.19 
155 mike          1.21     /** Optimized three-argument form of put().
156                        */
157 karl          1.19     static void put(
158 mike          1.21         LogFileType logFileType,
159                            const String& systemId,
160                            Uint32 logLevel,
161                            const String& formatString,
162                            const Formatter::Arg& arg0,
163                            const Formatter::Arg& arg1,
164                            const Formatter::Arg& arg2);
165 david         1.12 
166 chuck         1.15     /** put_l - Puts a localized message to the defined log file
167 mike          1.21         @param logFileType - Type of log file (Trace, etc.)
168 david.dillard 1.22         @param systemId  - ID of the system generating the log entry within
169 mike          1.21         Pegasus. This is user defined but generally breaks down into major
170                            Pegasus components.
171                            @param level logLevel of the log entry. To be used both t0
172 david.dillard 1.22         mark the log entry and tested against a mask to determine if log
173 mike          1.21         entry should be written.
174 david.dillard 1.22         @param messageId Message ID of the format string to load from
175                            the resource bundle.
176                            @param formatString     Default format definition string. See the
177 mike          1.21         Formatter for details.  This will be used as the default format string
178                            in case the resource bundle cannot be found.
179                            @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
180                            that go into the log entry.
181                            <pre>
182 kumpf         1.26         Logger::put(Logger::TRACE_LOG, System::CIMSERVER, Logger::WARNING,
183 mike          1.21             "X=$0, Y=$1, Z=$2", 88,  "Hello World", 7.5);
184                            </pre>
185 chuck         1.15     */
186                        static void put_l(
187 mike          1.21         LogFileType logFileType,
188                            const String& systemId,
189                            Uint32 logLevel,
190 david.dillard 1.22         const String& messageId,
191 mike          1.21         const String& formatString,
192                            const Formatter::Arg& arg0,
193                            const Formatter::Arg& arg1,
194                            const Formatter::Arg& arg2,
195                            const Formatter::Arg& arg3,
196                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
197                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
198                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
199                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
200                            const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
201                            const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
202 karl          1.19 
203 mike          1.21     /** Optimized zero-argument form of put_l().
204                        */
205                        static void put_l(
206                            LogFileType logFileType,
207                            const String& systemId,
208                            Uint32 logLevel,
209 david.dillard 1.22         const String& messageId,
210 mike          1.21         const String& formatString);
211                    
212                        /** Optimized one-argument form of put_l().
213                        */
214                        static void put_l(
215                            LogFileType logFileType,
216                            const String& systemId,
217                            Uint32 logLevel,
218 david.dillard 1.22         const String& messageId,
219 mike          1.21         const String& formatString,
220                            const Formatter::Arg& arg0);
221                    
222                        /** Optimized two-argument form of put_l().
223                        */
224 karl          1.19     static void put_l(
225 mike          1.21         LogFileType logFileType,
226                            const String& systemId,
227                            Uint32 logLevel,
228 david.dillard 1.22         const String& messageId,
229 mike          1.21         const String& formatString,
230                            const Formatter::Arg& arg0,
231                            const Formatter::Arg& arg1);
232 karl          1.19 
233 mike          1.21     /** Optimized three-argument form of put_l().
234                        */
235 karl          1.19     static void put_l(
236 mike          1.21         LogFileType logFileType,
237                            const String& systemId,
238                            Uint32 logLevel,
239 david.dillard 1.22         const String& messageId,
240 mike          1.21         const String& formatString,
241                            const Formatter::Arg& arg0,
242                            const Formatter::Arg& arg1,
243                            const Formatter::Arg& arg2);
244 chuck         1.15 
245 david.dillard 1.22     /** Puts a message to the define log. Should only be used for trace type
246 mike          1.21         logs.
247                        */
248 david         1.12     static void trace(
249 mike          1.21         LogFileType logFileType,
250                            const String& systemId,
251                            const Uint32 logComponent,
252                            const String& formatString,
253                            const Formatter::Arg& arg0,
254                            const Formatter::Arg& arg1,
255                            const Formatter::Arg& arg2,
256                            const Formatter::Arg& arg3,
257                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
258                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
259                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
260                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
261                            const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
262 david.dillard 1.22         const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
263 mike          1.21 
264                        /** Optimized three-argument form of trace().
265                        */
266                        static void trace(
267                            LogFileType logFileType,
268                            const String& systemId,
269                            const Uint32 logComponent,
270                            const String& formatString);
271                    
272                        /** Optimized one-argument form of trace().
273                        */
274                        static void trace(
275                            LogFileType logFileType,
276                            const String& systemId,
277                            const Uint32 logComponent,
278                            const String& formatString,
279                            const Formatter::Arg& arg0);
280                    
281                        /** Optimized two-argument form of trace().
282                        */
283                        static void trace(
284 mike          1.21         LogFileType logFileType,
285                            const String& systemId,
286                            const Uint32 logComponent,
287                            const String& formatString,
288                            const Formatter::Arg& arg0,
289                            const Formatter::Arg& arg1);
290                    
291                        /** Optimized three-argument form of trace().
292                        */
293                        static void trace(
294                            LogFileType logFileType,
295                            const String& systemId,
296                            const Uint32 logComponent,
297                            const String& formatString,
298                            const Formatter::Arg& arg0,
299                            const Formatter::Arg& arg1,
300                            const Formatter::Arg& arg2);
301 chuck         1.15 
302 mike          1.21     /** Puts a localized message to the log. Should only be used
303                            for trace type logs.
304                        */
305 chuck         1.15     static void trace_l(
306 mike          1.21         LogFileType logFileType,
307                            const String& systemId,
308                            const Uint32 logComponent,
309 david.dillard 1.22         const String& messageId,
310 mike          1.21         const String& formatString,
311                            const Formatter::Arg& arg0,
312                            const Formatter::Arg& arg1,
313                            const Formatter::Arg& arg2,
314                            const Formatter::Arg& arg3,
315                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
316                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
317                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
318                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
319                            const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
320                            const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
321 chuck         1.15 
322 mike          1.21     /** Optimized zero-argument form of trace_l().
323                        */
324                        static void trace_l(
325                            LogFileType logFileType,
326                            const String& systemId,
327                            const Uint32 logComponent,
328 david.dillard 1.22         const String& messageId,
329 mike          1.21         const String& formatString);
330                    
331                        /** Optimized one-argument form of trace_l().
332                        */
333                        static void trace_l(
334                            LogFileType logFileType,
335                            const String& systemId,
336                            const Uint32 logComponent,
337 david.dillard 1.22         const String& messageId,
338 mike          1.21         const String& formatString,
339                            const Formatter::Arg& arg0);
340                    
341                        /** Optimized two-argument form of trace_l().
342                        */
343                        static void trace_l(
344                            LogFileType logFileType,
345                            const String& systemId,
346                            const Uint32 logComponent,
347 david.dillard 1.22         const String& messageId,
348 mike          1.21         const String& formatString,
349                            const Formatter::Arg& arg0,
350                            const Formatter::Arg& arg1);
351                    
352                        /** Optimized three-argument form of trace_l().
353                        */
354                        static void trace_l(
355                            LogFileType logFileType,
356                            const String& systemId,
357                            const Uint32 logComponent,
358 david.dillard 1.22         const String& messageId,
359 mike          1.21         const String& formatString,
360                            const Formatter::Arg& arg0,
361                            const Formatter::Arg& arg1,
362                            const Formatter::Arg& arg2);
363                    
364 mike          1.8      /** setHomeDirectory
365                        */
366                        static void setHomeDirectory(const String& homeDirectory);
367                    
368 david         1.12     /** setlogLevelMask
369 mike          1.8      */
370 david         1.12     static void setlogLevelMask(const String logLevelList);
371 mike          1.8  
372 mike          1.21     /** Returns true if the given string is one of the legal log levels.
373                        */
374 david         1.12     static Boolean isValidlogLevel(const String logLevel);
375 mike          1.21 
376                        /** Tests if a log entry would be created by this call before
377                            the logger is called.  This function is intended to be used
378                            within the server for high usage log entries to avoid the
379                            overhead of doing the call when no log is created.
380                            @param logLevel Uint32 defining the level of the log to be
381                            executed.
382                            <p><b>Example:</b>
383                            <pre>
384                            if (Logger::wouldLog(Logger::TRACE))
385                            {
386 david.dillard 1.22             Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
387 mike          1.21                 Logger::TRACE, "HTTPMessage - HTTP header name: $0  "
388                                    "HTTP header value: $1" ,name,value);
389                            }
390                            </pre>
391                        */
392 david.dillard 1.22     static Boolean wouldLog(Uint32 logLevel)
393 mike          1.21     {
394 david.dillard 1.22         return (_severityMask & logLevel) != 0;
395 mike          1.21     }
396                    
397 mike          1.8  private:
398                    
399                        static LoggerRep* _rep;
400                        static String _homeDirectory;
401                        static Uint32 _severityMask;
402 david         1.12 
403                        static const Uint32 _NUM_LOGLEVEL;
404                    
405                        static void _putInternal(
406 mike          1.21         LogFileType logFileType,
407                            const String& systemId,
408                            const Uint32 logComponent,
409                            Uint32 logLevel,
410                            const String& formatString,
411                            const String& messageId,
412                            const Formatter::Arg& arg0 = Formatter::DEFAULT_ARG,
413                            const Formatter::Arg& arg1 = Formatter::DEFAULT_ARG,
414                            const Formatter::Arg& arg2 = Formatter::DEFAULT_ARG,
415                            const Formatter::Arg& arg3 = Formatter::DEFAULT_ARG,
416                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
417                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
418                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
419                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
420                            const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
421                            const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
422 mike          1.8  };
423                    
424                    PEGASUS_NAMESPACE_END
425                    
426                    #endif /* Pegasus_Logger_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2