00001 // Module: Log4CPLUS 00002 // File: Layout.h 00003 // Created: 6/2001 00004 // Author: Tad E. Smith 00005 // 00006 // 00007 // Copyright 2001-2009 Tad E. Smith 00008 // 00009 // Licensed under the Apache License, Version 2.0 (the "License"); 00010 // you may not use this file except in compliance with the License. 00011 // You may obtain a copy of the License at 00012 // 00013 // http://www.apache.org/licenses/LICENSE-2.0 00014 // 00015 // Unless required by applicable law or agreed to in writing, software 00016 // distributed under the License is distributed on an "AS IS" BASIS, 00017 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00018 // See the License for the specific language governing permissions and 00019 // limitations under the License. 00020 00023 #ifndef _LOG4CPLUS_LAYOUT_HEADER_ 00024 #define _LOG4CPLUS_LAYOUT_HEADER_ 00025 00026 #include "dcmtk/oflog/config.h" 00027 #include "dcmtk/oflog/loglevel.h" 00028 #include "dcmtk/oflog/streams.h" 00029 #include "dcmtk/oflog/tstring.h" 00030 #include "dcmtk/oflog/helpers/lloguser.h" 00031 #include "dcmtk/oflog/helpers/property.h" 00032 #include "dcmtk/oflog/helpers/timehelp.h" 00033 #include "dcmtk/oflog/spi/logevent.h" 00034 00035 //#include <vector> 00036 00037 00038 namespace log4cplus { 00039 00040 // Forward Declarations 00041 namespace pattern { 00042 class PatternConverter; 00043 } 00044 00045 00050 class LOG4CPLUS_EXPORT Layout : protected :: log4cplus::helpers::LogLogUser { 00051 public: 00052 Layout() : llmCache(getLogLevelManager()) {} 00053 Layout(const log4cplus::helpers::Properties&) 00054 : llmCache(getLogLevelManager()) {} 00055 virtual ~Layout() {} 00056 00057 virtual void formatAndAppend(log4cplus::tostream& output, 00058 const log4cplus::spi::InternalLoggingEvent& event) = 0; 00059 protected: 00060 LogLevelManager& llmCache; 00061 00062 private: 00063 // Disable copy 00064 Layout(const Layout&); 00065 Layout& operator=(Layout&); 00066 }; 00067 00068 00069 00080 class LOG4CPLUS_EXPORT SimpleLayout : public Layout { 00081 public: 00082 SimpleLayout() {} 00083 SimpleLayout(const log4cplus::helpers::Properties& properties, log4cplus::tstring&) : Layout(properties) {} 00084 00085 virtual void formatAndAppend(log4cplus::tostream& output, 00086 const log4cplus::spi::InternalLoggingEvent& event); 00087 00088 private: 00089 // Disallow copying of instances of this class 00090 SimpleLayout(const SimpleLayout&); 00091 SimpleLayout& operator=(const SimpleLayout&); 00092 }; 00093 00094 00095 00132 class LOG4CPLUS_EXPORT TTCCLayout : public Layout { 00133 public: 00134 // Ctor and dtor 00135 TTCCLayout(bool use_gmtime = false); 00136 TTCCLayout(const log4cplus::helpers::Properties& properties, log4cplus::tstring& error); 00137 virtual ~TTCCLayout(); 00138 00139 virtual void formatAndAppend(log4cplus::tostream& output, 00140 const log4cplus::spi::InternalLoggingEvent& event); 00141 00142 protected: 00143 log4cplus::tstring dateFormat; 00144 bool use_gmtime; 00145 00146 private: 00147 // Disallow copying of instances of this class 00148 TTCCLayout(const TTCCLayout&); 00149 TTCCLayout& operator=(const TTCCLayout&); 00150 }; 00151 00152 00153 00154 00514 class LOG4CPLUS_EXPORT PatternLayout : public Layout { 00515 public: 00516 // Ctors and dtor 00517 PatternLayout(const log4cplus::tstring& pattern, bool formatEachLine = true); 00518 PatternLayout(const log4cplus::helpers::Properties& properties, log4cplus::tstring& error); 00519 virtual ~PatternLayout(); 00520 00521 virtual void formatAndAppend(log4cplus::tostream& output, 00522 const log4cplus::spi::InternalLoggingEvent& event); 00523 00524 protected: 00525 void init(const log4cplus::tstring& pattern, bool formatEachLine); 00526 00527 // Data 00528 log4cplus::tstring pattern; 00529 bool formatEachLine; 00530 OFauto_ptr<OFList<pattern::PatternConverter*> > parsedPattern; 00531 00532 private: 00533 // Disallow copying of instances of this class 00534 PatternLayout(const PatternLayout&); 00535 PatternLayout& operator=(const PatternLayout&); 00536 }; 00537 00538 00539 00540 } // end namespace log4cplus 00541 00542 #endif // _LOG4CPLUS_LAYOUT_HEADER_ 00543