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

  1 karl  1.20 //%2005////////////////////////////////////////////////////////////////////////
  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 mike  1.8  //
 12            // Permission is hereby granted, free of charge, to any person obtaining a copy
 13 kumpf 1.10 // of this software and associated documentation files (the "Software"), to
 14            // deal in the Software without restriction, including without limitation the
 15            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 16 mike  1.8  // sell copies of the Software, and to permit persons to whom the Software is
 17            // furnished to do so, subject to the following conditions:
 18 david.dillard 1.22 //
 19 kumpf         1.10 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 20 mike          1.8  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 21                    // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 22 kumpf         1.10 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 23                    // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 24                    // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 25 mike          1.8  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 26                    // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27                    //
 28                    //==============================================================================
 29                    //
 30                    // Author: Mike Brasher (mbrasher@bmc.com)
 31                    //
 32 david         1.12 // Modified By: Dave Rosckes (rosckes@us.ibm.com)
 33 david.dillard 1.22 //              David Dillard, Symantec Corp. (david_dillard@symantec.com)
 34 mike          1.8  //
 35                    //%/////////////////////////////////////////////////////////////////////////////
 36                    
 37                    #ifndef Pegasus_Logger_h
 38                    #define Pegasus_Logger_h
 39                    
 40                    #include <Pegasus/Common/Config.h>
 41                    #include <Pegasus/Common/Formatter.h>
 42 kumpf         1.11 #include <Pegasus/Common/Linkage.h>
 43 david         1.14 #include <Pegasus/Common/System.h>
 44 mike          1.21 #include <Pegasus/Common/MessageLoader.h>
 45                    
 46                    #define PEG_LOGGER_TRACE(ARGS_LIST) \
 47                        do \
 48                        { \
 49                            if (Logger::wouldLog(Logger::TRACE)) \
 50                            { \
 51                                Logger::trace ARGS_LIST ; \
 52                            } \
 53                        } \
 54                        while (0)
 55 mike          1.8  
 56                    PEGASUS_NAMESPACE_BEGIN
 57                    
 58                    class LoggerRep;
 59                    
 60 mike          1.21 /** This class provides the interface for writing log records to the log.
 61 mike          1.8  */
 62                    class PEGASUS_COMMON_LINKAGE Logger
 63                    {
 64                    public:
 65                    
 66 david.dillard 1.22     enum LogFileType
 67 mike          1.21     {
 68 david.dillard 1.22         TRACE_LOG,
 69                            STANDARD_LOG,
 70 mike          1.21         ERROR_LOG,
 71                            DEBUG_LOG
 72 mike          1.8      };
 73 mike          1.21 
 74 mike          1.8      enum { NUM_LOGS = 4 };
 75 david.dillard 1.22 
 76                        /** Log file Level - Defines the loglevel of the log entry irrespective of
 77                            which log file it goes into. This is actually a bit mask as defined in
 78                            logger.cpp. Thus, it serves both as a level of indication of the
 79                            seriousness and possibly as a mask to select what is logged.
 80 mike          1.8          ATTN: The selection test has not been done.
 81                        */
 82                        static const Uint32 TRACE;
 83                        static const Uint32 INFORMATION;
 84                        static const Uint32 WARNING;
 85                        static const Uint32 SEVERE;
 86                        static const Uint32 FATAL;
 87                    
 88 mike          1.21     /** Puts a message to the defined log file
 89                            @param logFileType - Type of log file (Trace, etc.)
 90 david.dillard 1.22         @param systemId  - ID of the system generating the log entry within
 91 mike          1.21         Pegasus. This is user defined but generally breaks down into major
 92                            Pegasus components.
 93                            @param level logLevel of the log entry. To be used both t0
 94 david.dillard 1.22         mark the log entry and tested against a mask to determine if log
 95 mike          1.21         entry should be written.
 96 david.dillard 1.22         @param formatString     Format definition string for the Log. See the
 97 mike          1.21         Formatter for details.
 98                            @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
 99                            that go into the log entry.
100                            <pre>
101                            Logger::put(Logger::TRACE_LOG, "CIMServer", Logger::WARNING,
102                                "X=$0, Y=$1, Z=$2", 88,  "Hello World", 7.5);
103                            </pre>
104                        */
105                        static void put(
106                            LogFileType logFileType,
107                            const String& systemId,
108                            Uint32 logLevel,
109                            const String& formatString,
110                            const Formatter::Arg& arg0,
111                            const Formatter::Arg& arg1,
112                            const Formatter::Arg& arg2,
113                            const Formatter::Arg& arg3,
114                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
115                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
116                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
117                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
118 mike          1.21         const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
119                            const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
120                    
121                        /** Optimized zero-argument form of put().
122                        */
123                        static void put(
124                            LogFileType logFileType,
125                            const String& systemId,
126                            Uint32 logLevel,
127                            const String& formatString);
128 david         1.12 
129 mike          1.21     /** Optimized one-argument form of put().
130 mike          1.8      */
131                        static void put(
132 mike          1.21         LogFileType logFileType,
133                            const String& systemId,
134                            Uint32 logLevel,
135                            const String& formatString,
136                            const Formatter::Arg& arg0);
137 karl          1.19 
138 mike          1.21     /** Optimized two-argument form of put().
139                        */
140 karl          1.19     static void put(
141 mike          1.21         LogFileType logFileType,
142                            const String& systemId,
143                            Uint32 logLevel,
144                            const String& formatString,
145                            const Formatter::Arg& arg0,
146                            const Formatter::Arg& arg1);
147 karl          1.19 
148 mike          1.21     /** Optimized three-argument form of put().
149                        */
150 karl          1.19     static void put(
151 mike          1.21         LogFileType logFileType,
152                            const String& systemId,
153                            Uint32 logLevel,
154                            const String& formatString,
155                            const Formatter::Arg& arg0,
156                            const Formatter::Arg& arg1,
157                            const Formatter::Arg& arg2);
158 david         1.12 
159 chuck         1.15     /** put_l - Puts a localized message to the defined log file
160 mike          1.21         @param logFileType - Type of log file (Trace, etc.)
161 david.dillard 1.22         @param systemId  - ID of the system generating the log entry within
162 mike          1.21         Pegasus. This is user defined but generally breaks down into major
163                            Pegasus components.
164                            @param level logLevel of the log entry. To be used both t0
165 david.dillard 1.22         mark the log entry and tested against a mask to determine if log
166 mike          1.21         entry should be written.
167 david.dillard 1.22         @param messageId Message ID of the format string to load from
168                            the resource bundle.
169                            @param formatString     Default format definition string. See the
170 mike          1.21         Formatter for details.  This will be used as the default format string
171                            in case the resource bundle cannot be found.
172                            @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
173                            that go into the log entry.
174                            <pre>
175                            Logger::put(Logger::TRACE_LOG, "CIMServer", Logger::WARNING,
176                                "X=$0, Y=$1, Z=$2", 88,  "Hello World", 7.5);
177                            </pre>
178 chuck         1.15     */
179                        static void put_l(
180 mike          1.21         LogFileType logFileType,
181                            const String& systemId,
182                            Uint32 logLevel,
183 david.dillard 1.22         const String& messageId,
184 mike          1.21         const String& formatString,
185                            const Formatter::Arg& arg0,
186                            const Formatter::Arg& arg1,
187                            const Formatter::Arg& arg2,
188                            const Formatter::Arg& arg3,
189                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
190                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
191                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
192                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
193                            const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
194                            const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
195 karl          1.19 
196 mike          1.21     /** Optimized zero-argument form of put_l().
197                        */
198                        static void put_l(
199                            LogFileType logFileType,
200                            const String& systemId,
201                            Uint32 logLevel,
202 david.dillard 1.22         const String& messageId,
203 mike          1.21         const String& formatString);
204                    
205                        /** Optimized one-argument form of put_l().
206                        */
207                        static void put_l(
208                            LogFileType logFileType,
209                            const String& systemId,
210                            Uint32 logLevel,
211 david.dillard 1.22         const String& messageId,
212 mike          1.21         const String& formatString,
213                            const Formatter::Arg& arg0);
214                    
215                        /** Optimized two-argument form of put_l().
216                        */
217 karl          1.19     static void put_l(
218 mike          1.21         LogFileType logFileType,
219                            const String& systemId,
220                            Uint32 logLevel,
221 david.dillard 1.22         const String& messageId,
222 mike          1.21         const String& formatString,
223                            const Formatter::Arg& arg0,
224                            const Formatter::Arg& arg1);
225 karl          1.19 
226 mike          1.21     /** Optimized three-argument form of put_l().
227                        */
228 karl          1.19     static void put_l(
229 mike          1.21         LogFileType logFileType,
230                            const String& systemId,
231                            Uint32 logLevel,
232 david.dillard 1.22         const String& messageId,
233 mike          1.21         const String& formatString,
234                            const Formatter::Arg& arg0,
235                            const Formatter::Arg& arg1,
236                            const Formatter::Arg& arg2);
237 chuck         1.15 
238 david.dillard 1.22     /** Puts a message to the define log. Should only be used for trace type
239 mike          1.21         logs.
240                        */
241 david         1.12     static void trace(
242 mike          1.21         LogFileType logFileType,
243                            const String& systemId,
244                            const Uint32 logComponent,
245                            const String& formatString,
246                            const Formatter::Arg& arg0,
247                            const Formatter::Arg& arg1,
248                            const Formatter::Arg& arg2,
249                            const Formatter::Arg& arg3,
250                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
251                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
252                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
253                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
254                            const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
255 david.dillard 1.22         const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
256 mike          1.21 
257                        /** Optimized three-argument form of trace().
258                        */
259                        static void trace(
260                            LogFileType logFileType,
261                            const String& systemId,
262                            const Uint32 logComponent,
263                            const String& formatString);
264                    
265                        /** Optimized one-argument form of trace().
266                        */
267                        static void trace(
268                            LogFileType logFileType,
269                            const String& systemId,
270                            const Uint32 logComponent,
271                            const String& formatString,
272                            const Formatter::Arg& arg0);
273                    
274                        /** Optimized two-argument form of trace().
275                        */
276                        static void trace(
277 mike          1.21         LogFileType logFileType,
278                            const String& systemId,
279                            const Uint32 logComponent,
280                            const String& formatString,
281                            const Formatter::Arg& arg0,
282                            const Formatter::Arg& arg1);
283                    
284                        /** Optimized three-argument form of trace().
285                        */
286                        static void trace(
287                            LogFileType logFileType,
288                            const String& systemId,
289                            const Uint32 logComponent,
290                            const String& formatString,
291                            const Formatter::Arg& arg0,
292                            const Formatter::Arg& arg1,
293                            const Formatter::Arg& arg2);
294 chuck         1.15 
295 mike          1.21     /** Puts a localized message to the log. Should only be used
296                            for trace type logs.
297                        */
298 chuck         1.15     static void trace_l(
299 mike          1.21         LogFileType logFileType,
300                            const String& systemId,
301                            const Uint32 logComponent,
302 david.dillard 1.22         const String& messageId,
303 mike          1.21         const String& formatString,
304                            const Formatter::Arg& arg0,
305                            const Formatter::Arg& arg1,
306                            const Formatter::Arg& arg2,
307                            const Formatter::Arg& arg3,
308                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
309                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
310                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
311                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
312                            const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
313                            const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
314 chuck         1.15 
315 mike          1.21     /** Optimized zero-argument form of trace_l().
316                        */
317                        static void trace_l(
318                            LogFileType logFileType,
319                            const String& systemId,
320                            const Uint32 logComponent,
321 david.dillard 1.22         const String& messageId,
322 mike          1.21         const String& formatString);
323                    
324                        /** Optimized one-argument form of trace_l().
325                        */
326                        static void trace_l(
327                            LogFileType logFileType,
328                            const String& systemId,
329                            const Uint32 logComponent,
330 david.dillard 1.22         const String& messageId,
331 mike          1.21         const String& formatString,
332                            const Formatter::Arg& arg0);
333                    
334                        /** Optimized two-argument form of trace_l().
335                        */
336                        static void trace_l(
337                            LogFileType logFileType,
338                            const String& systemId,
339                            const Uint32 logComponent,
340 david.dillard 1.22         const String& messageId,
341 mike          1.21         const String& formatString,
342                            const Formatter::Arg& arg0,
343                            const Formatter::Arg& arg1);
344                    
345                        /** Optimized three-argument form of trace_l().
346                        */
347                        static void trace_l(
348                            LogFileType logFileType,
349                            const String& systemId,
350                            const Uint32 logComponent,
351 david.dillard 1.22         const String& messageId,
352 mike          1.21         const String& formatString,
353                            const Formatter::Arg& arg0,
354                            const Formatter::Arg& arg1,
355                            const Formatter::Arg& arg2);
356                    
357 mike          1.8      /** setHomeDirectory
358                        */
359                        static void setHomeDirectory(const String& homeDirectory);
360                    
361 david         1.12     /** setlogLevelMask
362 mike          1.8      */
363 david         1.12     static void setlogLevelMask(const String logLevelList);
364 mike          1.8  
365                        /** setLogWriteControlMask
366                        */
367                        static void setLogWriteControlMask(const Uint32);
368                    
369 mike          1.21     /** Returns true if the given string is one of the legal log levels.
370                        */
371 david         1.12     static Boolean isValidlogLevel(const String logLevel);
372 mike          1.21 
373                        /** Tests if a log entry would be created by this call before
374                            the logger is called.  This function is intended to be used
375                            within the server for high usage log entries to avoid the
376                            overhead of doing the call when no log is created.
377                            @param logLevel Uint32 defining the level of the log to be
378                            executed.
379                            <p><b>Example:</b>
380                            <pre>
381                            if (Logger::wouldLog(Logger::TRACE))
382                            {
383 david.dillard 1.22             Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
384 mike          1.21                 Logger::TRACE, "HTTPMessage - HTTP header name: $0  "
385                                    "HTTP header value: $1" ,name,value);
386                            }
387                            </pre>
388                        */
389 david.dillard 1.22     static Boolean wouldLog(Uint32 logLevel)
390 mike          1.21     {
391 david.dillard 1.22         return (_severityMask & logLevel) != 0;
392 mike          1.21     }
393                    
394 mike          1.8  private:
395                    
396                        static LoggerRep* _rep;
397                        static String _homeDirectory;
398                        static Uint32 _severityMask;
399                        static Uint32 _writeControlMask;
400 david         1.12 
401                        static const char   _SEPARATOR;
402                        static const Uint32 _NUM_LOGLEVEL;
403                    
404                        static const Boolean _SUCCESS;
405                        static const Boolean _FAILURE;
406 mike          1.21 
407 david         1.12     static void _putInternal(
408 mike          1.21         LogFileType logFileType,
409                            const String& systemId,
410                            const Uint32 logComponent,
411                            Uint32 logLevel,
412                            const String& formatString,
413                            const String& messageId,
414                            const Formatter::Arg& arg0 = Formatter::DEFAULT_ARG,
415                            const Formatter::Arg& arg1 = Formatter::DEFAULT_ARG,
416                            const Formatter::Arg& arg2 = Formatter::DEFAULT_ARG,
417                            const Formatter::Arg& arg3 = Formatter::DEFAULT_ARG,
418                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
419                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
420                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
421                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
422                            const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
423                            const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
424 mike          1.8  };
425                    
426                    PEGASUS_NAMESPACE_END
427                    
428                    #endif /* Pegasus_Logger_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2