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

  1 martin 1.38 //%LICENSE////////////////////////////////////////////////////////////////
  2             // 
  3             // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9             // 
 10             // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16             // 
 17             // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19             // 
 20             // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21             // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 22 martin 1.38 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 karl   1.24 // 
 28 martin 1.38 //////////////////////////////////////////////////////////////////////////
 29 mike   1.8  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #ifndef Pegasus_Logger_h
 33             #define Pegasus_Logger_h
 34             
 35             #include <Pegasus/Common/Config.h>
 36             #include <Pegasus/Common/Formatter.h>
 37 kumpf  1.11 #include <Pegasus/Common/Linkage.h>
 38 david  1.14 #include <Pegasus/Common/System.h>
 39 mike   1.21 #include <Pegasus/Common/MessageLoader.h>
 40             
 41 mike   1.8  PEGASUS_NAMESPACE_BEGIN
 42             
 43             class LoggerRep;
 44             
 45 mike   1.21 /** This class provides the interface for writing log records to the log.
 46 mike   1.8  */
 47             class PEGASUS_COMMON_LINKAGE Logger
 48             {
 49             public:
 50             
 51 david.dillard 1.22     enum LogFileType
 52 mike          1.21     {
 53 david.dillard 1.22         TRACE_LOG,
 54                            STANDARD_LOG,
 55 kumpf         1.30         AUDIT_LOG, // Use only if PEGASUS_ENABLE_AUDIT_LOGGER is defined
 56 marek         1.32         ERROR_LOG
 57 mike          1.8      };
 58 mike          1.21 
 59 marek         1.32     enum { NUM_LOGS = 4 };
 60 david.dillard 1.22 
 61                        /** Log file Level - Defines the loglevel of the log entry irrespective of
 62                            which log file it goes into. This is actually a bit mask as defined in
 63                            logger.cpp. Thus, it serves both as a level of indication of the
 64                            seriousness and possibly as a mask to select what is logged.
 65 mike          1.8          ATTN: The selection test has not been done.
 66                        */
 67                        static const Uint32 TRACE;
 68                        static const Uint32 INFORMATION;
 69                        static const Uint32 WARNING;
 70                        static const Uint32 SEVERE;
 71                        static const Uint32 FATAL;
 72                    
 73 mike          1.21     /** Puts a message to the defined log file
 74                            @param logFileType - Type of log file (Trace, etc.)
 75 david.dillard 1.22         @param systemId  - ID of the system generating the log entry within
 76 mike          1.21         Pegasus. This is user defined but generally breaks down into major
 77                            Pegasus components.
 78                            @param level logLevel of the log entry. To be used both t0
 79 david.dillard 1.22         mark the log entry and tested against a mask to determine if log
 80 mike          1.21         entry should be written.
 81 david.dillard 1.22         @param formatString     Format definition string for the Log. See the
 82 mike          1.21         Formatter for details.
 83                            @param Arg0 - Arg 9 - Up to 9 arguments representing the variables
 84                            that go into the log entry.
 85                            <pre>
 86 kumpf         1.26         Logger::put(Logger::TRACE_LOG, System::CIMSERVER, Logger::WARNING,
 87 mike          1.21             "X=$0, Y=$1, Z=$2", 88,  "Hello World", 7.5);
 88                            </pre>
 89                        */
 90                        static void put(
 91                            LogFileType logFileType,
 92                            const String& systemId,
 93                            Uint32 logLevel,
 94                            const String& formatString,
 95                            const Formatter::Arg& arg0,
 96                            const Formatter::Arg& arg1,
 97                            const Formatter::Arg& arg2,
 98                            const Formatter::Arg& arg3,
 99                            const Formatter::Arg& arg4 = Formatter::DEFAULT_ARG,
100                            const Formatter::Arg& arg5 = Formatter::DEFAULT_ARG,
101                            const Formatter::Arg& arg6 = Formatter::DEFAULT_ARG,
102                            const Formatter::Arg& arg7 = Formatter::DEFAULT_ARG,
103                            const Formatter::Arg& arg8 = Formatter::DEFAULT_ARG,
104                            const Formatter::Arg& arg9 = Formatter::DEFAULT_ARG);
105                    
106                        /** Optimized zero-argument form of put().
107                        */
108 mike          1.21     static void put(
109                            LogFileType logFileType,
110                            const String& systemId,
111                            Uint32 logLevel,
112                            const String& formatString);
113 david         1.12 
114 mike          1.21     /** Optimized one-argument form of put().
115 mike          1.8      */
116                        static void put(
117 mike          1.21         LogFileType logFileType,
118                            const String& systemId,
119                            Uint32 logLevel,
120                            const String& formatString,
121                            const Formatter::Arg& arg0);
122 karl          1.19 
123 mike          1.21     /** Optimized two-argument form of put().
124                        */
125 karl          1.19     static void put(
126 mike          1.21         LogFileType logFileType,
127                            const String& systemId,
128                            Uint32 logLevel,
129                            const String& formatString,
130                            const Formatter::Arg& arg0,
131                            const Formatter::Arg& arg1);
132 karl          1.19 
133 mike          1.21     /** Optimized three-argument form of put().
134                        */
135 karl          1.19     static void put(
136 mike          1.21         LogFileType logFileType,
137                            const String& systemId,
138                            Uint32 logLevel,
139                            const String& formatString,
140                            const Formatter::Arg& arg0,
141                            const Formatter::Arg& arg1,
142                            const Formatter::Arg& arg2);
143 david         1.12 
144 chuck         1.15     /** put_l - Puts a localized message to the defined log file
145 mike          1.21         @param logFileType - Type of log file (Trace, etc.)
146 david.dillard 1.22         @param systemId  - ID of the system generating the log entry within
147 mike          1.21         Pegasus. This is user defined but generally breaks down into major
148                            Pegasus components.
149 kumpf         1.36         @param level logLevel of the log entry. To be used both to
150 david.dillard 1.22         mark the log entry and tested against a mask to determine if log
151 mike          1.21         entry should be written.
152 kumpf         1.36         @param msgParms MessageLoaderParms object containing the localizable
153                            message to log.
154 mike          1.21     */
155                        static void put_l(
156                            LogFileType logFileType,
157                            const String& systemId,
158                            Uint32 logLevel,
159 kumpf         1.36         const MessageLoaderParms& msgParms);
160 chuck         1.15 
161 kumpf         1.35     /** Puts a trace message into the specified log.
162 mike          1.21     */
163 david         1.12     static void trace(
164 mike          1.21         LogFileType logFileType,
165                            const String& systemId,
166                            const Uint32 logComponent,
167 kumpf         1.35         const String& message);
168 mike          1.21 
169 mike          1.8      /** setHomeDirectory
170                        */
171                        static void setHomeDirectory(const String& homeDirectory);
172                    
173 david         1.12     /** setlogLevelMask
174 mike          1.8      */
175 david         1.12     static void setlogLevelMask(const String logLevelList);
176 mike          1.8  
177 mike          1.21     /** Returns true if the given string is one of the legal log levels.
178                        */
179 david         1.12     static Boolean isValidlogLevel(const String logLevel);
180 mike          1.21 
181                        /** Tests if a log entry would be created by this call before
182                            the logger is called.  This function is intended to be used
183                            within the server for high usage log entries to avoid the
184                            overhead of doing the call when no log is created.
185                            @param logLevel Uint32 defining the level of the log to be
186                            executed.
187                            <p><b>Example:</b>
188                            <pre>
189                            if (Logger::wouldLog(Logger::TRACE))
190                            {
191 david.dillard 1.22             Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
192 mike          1.21                 Logger::TRACE, "HTTPMessage - HTTP header name: $0  "
193                                    "HTTP header value: $1" ,name,value);
194                            }
195                            </pre>
196                        */
197 david.dillard 1.22     static Boolean wouldLog(Uint32 logLevel)
198 mike          1.21     {
199 david.dillard 1.22         return (_severityMask & logLevel) != 0;
200 mike          1.21     }
201                    
202 mreddy        1.37 #if !defined(PEGASUS_USE_SYSLOGS)
203                        static void setMaxLogFileSize (Uint32 maxLogFileSizeBytes);
204                    #endif
205                    
206 mike          1.8  private:
207                    
208                        static LoggerRep* _rep;
209                        static String _homeDirectory;
210                        static Uint32 _severityMask;
211 david         1.12     static const Uint32 _NUM_LOGLEVEL;
212                    
213                        static void _putInternal(
214 mike          1.21         LogFileType logFileType,
215                            const String& systemId,
216                            const Uint32 logComponent,
217                            Uint32 logLevel,
218 kumpf         1.36         const String& message);
219 mike          1.8  };
220                    
221                    PEGASUS_NAMESPACE_END
222                    
223                    #endif /* Pegasus_Logger_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2