log4cplus
1.1.0
|
00001 // -*- C++ -*- 00002 // Module: Log4CPLUS 00003 // File: loglevel.h 00004 // Created: 6/2001 00005 // Author: Tad E. Smith 00006 // 00007 // 00008 // Copyright 2001-2010 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 union 00182 { 00183 LogLevelToStringMethod func; 00184 LogLevelToStringMethod_1_0 func_1_0; 00185 }; 00186 bool use_1_0; 00187 }; 00188 00189 typedef std::vector<LogLevelToStringMethodRec> LogLevelToStringMethodList; 00190 LogLevelToStringMethodList toStringMethods; 00191 00192 typedef std::vector<StringToLogLevelMethod> StringToLogLevelMethodList; 00193 StringToLogLevelMethodList fromStringMethods; 00194 00195 // Disable Copy 00196 LogLevelManager(const LogLevelManager&); 00197 LogLevelManager& operator=(const LogLevelManager&); 00198 }; 00199 00203 LOG4CPLUS_EXPORT LogLevelManager& getLogLevelManager(); 00204 00205 } 00206 00207 00208 #endif // LOG4CPLUS_LOGLEVEL_HEADER_ 00209