log4cplus
2.0.0
|
00001 // -*- C++ -*- 00002 // Module: Log4CPLUS 00003 // File: loglog.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 00024 #ifndef LOG4CPLUS_HELPERS_LOGLOG 00025 #define LOG4CPLUS_HELPERS_LOGLOG 00026 00027 #include <log4cplus/config.hxx> 00028 00029 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 00030 #pragma once 00031 #endif 00032 00033 #include <log4cplus/tstring.h> 00034 #include <log4cplus/streams.h> 00035 #include <log4cplus/thread/syncprims.h> 00036 00037 00038 namespace log4cplus { 00039 namespace helpers { 00040 00054 class LOG4CPLUS_EXPORT LogLog 00055 { 00056 public: 00058 typedef LogLog * Ptr; 00059 00063 static Ptr getLogLog(); 00064 00065 00069 void setInternalDebugging(bool enabled); 00070 00077 void setQuietMode(bool quietMode); 00078 00083 void debug(const log4cplus::tstring& msg) const; 00084 void debug(tchar const * msg) const; 00085 00093 void error(const log4cplus::tstring& msg, bool throw_flag = false) const; 00094 void error(tchar const * msg, bool throw_flag = false) const; 00095 00101 void warn(const log4cplus::tstring& msg) const; 00102 void warn(tchar const * msg) const; 00103 00104 // Public ctor and dtor to be used only by internal::DefaultContext. 00105 LogLog(); 00106 virtual ~LogLog(); 00107 00108 private: 00109 enum TriState 00110 { 00111 TriUndef = -1, 00112 TriFalse, 00113 TriTrue 00114 }; 00115 00116 template <typename StringType> 00117 LOG4CPLUS_PRIVATE 00118 void logging_worker (tostream & os, 00119 bool (LogLog:: * cond) () const, tchar const *, 00120 StringType const &, bool throw_flag = false) const; 00121 00122 LOG4CPLUS_PRIVATE static void set_tristate_from_env (TriState *, 00123 tchar const * envvar); 00124 00125 LOG4CPLUS_PRIVATE bool get_quiet_mode () const; 00126 LOG4CPLUS_PRIVATE bool get_not_quiet_mode () const; 00127 LOG4CPLUS_PRIVATE bool get_debug_mode () const; 00128 00129 // Data 00130 mutable TriState debugEnabled; 00131 mutable TriState quietMode; 00132 thread::Mutex mutex; 00133 00134 LOG4CPLUS_PRIVATE LogLog(const LogLog&); 00135 LOG4CPLUS_PRIVATE LogLog & operator = (LogLog const &); 00136 }; 00137 00138 LOG4CPLUS_EXPORT LogLog & getLogLog (); 00139 00140 } // end namespace helpers 00141 } // end namespace log4cplus 00142 00143 00144 #endif // LOG4CPLUS_HELPERS_LOGLOG 00145