log4cplus  2.0.0
loglevel.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Module:  Log4CPLUS
00003 // File:    loglevel.h
00004 // Created: 6/2001
00005 // Author:  Tad E. Smith
00006 //
00007 //
00008 // Copyright 2001-2015 Tad E. Smith
00009 //
00010 // Licensed under the Apache License, Version 2.0 (the "License");
00011 // you may not use this file except in compliance with the License.
00012 // You may obtain a copy of the License at
00013 //
00014 //     http://www.apache.org/licenses/LICENSE-2.0
00015 //
00016 // Unless required by applicable law or agreed to in writing, software
00017 // distributed under the License is distributed on an "AS IS" BASIS,
00018 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019 // See the License for the specific language governing permissions and
00020 // limitations under the License.
00021 
00026 #ifndef LOG4CPLUS_LOGLEVEL_HEADER_
00027 #define LOG4CPLUS_LOGLEVEL_HEADER_
00028 
00029 #include <log4cplus/config.hxx>
00030 
00031 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
00032 #pragma once
00033 #endif
00034 
00035 #include <vector>
00036 #include <log4cplus/tstring.h>
00037 
00038 
00039 namespace log4cplus {
00040 
00048     typedef int LogLevel;
00049 
00053     const LogLevel OFF_LOG_LEVEL     = 60000;
00054 
00058     const LogLevel FATAL_LOG_LEVEL   = 50000;
00059 
00063     const LogLevel ERROR_LOG_LEVEL   = 40000;
00064 
00068     const LogLevel WARN_LOG_LEVEL    = 30000;
00069 
00074     const LogLevel INFO_LOG_LEVEL    = 20000;
00075 
00079     const LogLevel DEBUG_LOG_LEVEL   = 10000;
00080 
00084     const LogLevel TRACE_LOG_LEVEL   = 0;
00085 
00089     const LogLevel ALL_LOG_LEVEL     = TRACE_LOG_LEVEL;
00090 
00095     const LogLevel NOT_SET_LOG_LEVEL = -1;
00096 
00097 
00104     typedef log4cplus::tstring const & (*LogLevelToStringMethod)(LogLevel);
00105 
00107     typedef log4cplus::tstring (*LogLevelToStringMethod_1_0) (LogLevel);
00108 
00109 
00116     typedef LogLevel (*StringToLogLevelMethod)(const log4cplus::tstring&);
00117 
00118 
00119 
00133     class LOG4CPLUS_EXPORT LogLevelManager {
00134     public:
00135         LogLevelManager();
00136         ~LogLevelManager();
00137 
00145         log4cplus::tstring const & toString(LogLevel ll) const;
00146 
00154         LogLevel fromString(const log4cplus::tstring& s) const;
00155 
00163         void pushToStringMethod(LogLevelToStringMethod newToString);
00164 
00166         void pushToStringMethod(LogLevelToStringMethod_1_0 newToString);
00167 
00175         void pushFromStringMethod(StringToLogLevelMethod newFromString);
00176 
00177     private:
00178       // Data
00179         struct LogLevelToStringMethodRec
00180         {
00181             LogLevelToStringMethodRec ();
00182             LogLevelToStringMethodRec (LogLevelToStringMethod);
00183             LogLevelToStringMethodRec (LogLevelToStringMethod_1_0);
00184 
00185             union
00186             {
00187                 LogLevelToStringMethod func;
00188                 LogLevelToStringMethod_1_0 func_1_0;
00189             };
00190             bool use_1_0;
00191         };
00192 
00193         typedef std::vector<LogLevelToStringMethodRec> LogLevelToStringMethodList;
00194         LogLevelToStringMethodList toStringMethods;
00195 
00196         typedef std::vector<StringToLogLevelMethod> StringToLogLevelMethodList;
00197         StringToLogLevelMethodList fromStringMethods;
00198 
00199       // Disable Copy
00200         LogLevelManager(const LogLevelManager&);
00201         LogLevelManager& operator=(const LogLevelManager&);
00202     };
00203 
00207     LOG4CPLUS_EXPORT LogLevelManager& getLogLevelManager();
00208 
00209 }
00210 
00211 
00212 #endif // LOG4CPLUS_LOGLEVEL_HEADER_