log4cplus
1.1.0
|
00001 // -*- C++ -*- 00002 // Module: Log4CPLUS 00003 // File: Layout.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 00024 #ifndef LOG4CPLUS_LAYOUT_HEADER_ 00025 #define LOG4CPLUS_LAYOUT_HEADER_ 00026 00027 #include <log4cplus/config.hxx> 00028 00029 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 00030 #pragma once 00031 #endif 00032 00033 #include <log4cplus/loglevel.h> 00034 #include <log4cplus/streams.h> 00035 #include <log4cplus/tstring.h> 00036 00037 #include <vector> 00038 00039 00040 namespace log4cplus { 00041 00042 // Forward Declarations 00043 namespace pattern 00044 { 00045 00046 class PatternConverter; 00047 00048 } 00049 00050 00051 namespace helpers 00052 { 00053 00054 class Properties; 00055 class Time; 00056 00057 } 00058 00059 00060 namespace spi 00061 { 00062 00063 class InternalLoggingEvent; 00064 00065 } 00066 00067 00072 class LOG4CPLUS_EXPORT Layout 00073 { 00074 public: 00075 Layout(); 00076 Layout(const helpers::Properties& properties); 00077 virtual ~Layout() = 0; 00078 00079 virtual void formatAndAppend(log4cplus::tostream& output, 00080 const log4cplus::spi::InternalLoggingEvent& event) = 0; 00081 00082 protected: 00083 LogLevelManager& llmCache; 00084 00085 private: 00086 // Disable copy 00087 Layout(const Layout&); 00088 Layout& operator=(Layout const &); 00089 }; 00090 00091 00092 00103 class LOG4CPLUS_EXPORT SimpleLayout 00104 : public Layout 00105 { 00106 public: 00107 SimpleLayout(); 00108 SimpleLayout(const log4cplus::helpers::Properties& properties); 00109 virtual ~SimpleLayout(); 00110 00111 virtual void formatAndAppend(log4cplus::tostream& output, 00112 const log4cplus::spi::InternalLoggingEvent& event); 00113 00114 private: 00115 // Disallow copying of instances of this class 00116 SimpleLayout(const SimpleLayout&); 00117 SimpleLayout& operator=(const SimpleLayout&); 00118 }; 00119 00120 00121 00158 class LOG4CPLUS_EXPORT TTCCLayout 00159 : public Layout 00160 { 00161 public: 00162 // Ctor and dtor 00163 TTCCLayout(bool use_gmtime = false); 00164 TTCCLayout(const log4cplus::helpers::Properties& properties); 00165 virtual ~TTCCLayout(); 00166 00167 virtual void formatAndAppend(log4cplus::tostream& output, 00168 const log4cplus::spi::InternalLoggingEvent& event); 00169 00170 protected: 00171 log4cplus::tstring dateFormat; 00172 bool use_gmtime; 00173 00174 private: 00175 // Disallow copying of instances of this class 00176 TTCCLayout(const TTCCLayout&); 00177 TTCCLayout& operator=(const TTCCLayout&); 00178 }; 00179 00180 00181 LOG4CPLUS_EXPORT helpers::Time const & getTTCCLayoutTimeBase (); 00182 00183 00569 class LOG4CPLUS_EXPORT PatternLayout 00570 : public Layout 00571 { 00572 public: 00573 // Ctors and dtor 00574 PatternLayout(const log4cplus::tstring& pattern); 00575 PatternLayout(const log4cplus::helpers::Properties& properties); 00576 virtual ~PatternLayout(); 00577 00578 virtual void formatAndAppend(log4cplus::tostream& output, 00579 const log4cplus::spi::InternalLoggingEvent& event); 00580 00581 protected: 00582 void init(const log4cplus::tstring& pattern, unsigned ndcMaxDepth = 0); 00583 00584 // Data 00585 log4cplus::tstring pattern; 00586 std::vector<pattern::PatternConverter*> parsedPattern; 00587 00588 private: 00589 // Disallow copying of instances of this class 00590 PatternLayout(const PatternLayout&); 00591 PatternLayout& operator=(const PatternLayout&); 00592 }; 00593 00594 00595 00596 } // end namespace log4cplus 00597 00598 #endif // LOG4CPLUS_LAYOUT_HEADER_ 00599