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

  1 martin 1.38 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.39 //
  3 martin 1.38 // 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 martin 1.39 //
 10 martin 1.38 // 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 martin 1.39 //
 17 martin 1.38 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.39 //
 20 martin 1.38 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.39 // 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 martin 1.39 //
 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 kumpf         1.35         const String& message);
167 mike          1.21 
168 mike          1.8      /** setHomeDirectory
169                        */
170                        static void setHomeDirectory(const String& homeDirectory);
171                    
172 david         1.12     /** setlogLevelMask
173 mike          1.8      */
174 karl          1.39.8.1     static void setlogLevelMask(const String &logLevelList);
175 mike          1.8      
176 mike          1.21         /** Returns true if the given string is one of the legal log levels.
177                            */
178 karl          1.39.8.1     static Boolean isValidlogLevel(const String &logLevel);
179 mike          1.21     
180                            /** Tests if a log entry would be created by this call before
181                                the logger is called.  This function is intended to be used
182                                within the server for high usage log entries to avoid the
183                                overhead of doing the call when no log is created.
184                                @param logLevel Uint32 defining the level of the log to be
185                                executed.
186                                <p><b>Example:</b>
187                                <pre>
188                                if (Logger::wouldLog(Logger::TRACE))
189                                {
190 david.dillard 1.22                 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
191 mike          1.21                     Logger::TRACE, "HTTPMessage - HTTP header name: $0  "
192                                        "HTTP header value: $1" ,name,value);
193                                }
194                                </pre>
195                            */
196 david.dillard 1.22         static Boolean wouldLog(Uint32 logLevel)
197 mike          1.21         {
198 david.dillard 1.22             return (_severityMask & logLevel) != 0;
199 mike          1.21         }
200                        
201 mreddy        1.37     #if !defined(PEGASUS_USE_SYSLOGS)
202                            static void setMaxLogFileSize (Uint32 maxLogFileSizeBytes);
203                        #endif
204                        
205 mike          1.8      private:
206                        
207                            static LoggerRep* _rep;
208                            static String _homeDirectory;
209                            static Uint32 _severityMask;
210 david         1.12         static const Uint32 _NUM_LOGLEVEL;
211                        
212                            static void _putInternal(
213 mike          1.21             LogFileType logFileType,
214                                const String& systemId,
215                                Uint32 logLevel,
216 kumpf         1.36             const String& message);
217 mike          1.8      };
218                        
219                        PEGASUS_NAMESPACE_END
220                        
221                        #endif /* Pegasus_Logger_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2