00001 /* 00002 * PatternLayout.hh 00003 * 00004 * Copyright 2002, Bastiaan Bakker. All rights reserved. 00005 * 00006 * See the COPYING file for the terms of usage and distribution. 00007 */ 00008 00009 #ifndef _LOG4CPP_PATTERNLAYOUT_HH 00010 #define _LOG4CPP_PATTERNLAYOUT_HH 00011 00012 #include <log4cpp/Portability.hh> 00013 #include <log4cpp/Layout.hh> 00014 #include <log4cpp/Configurator.hh> 00015 #include <vector> 00016 #ifdef LOG4CPP_HAVE_SSTREAM 00017 #include <sstream> 00018 #endif 00019 00020 namespace log4cpp { 00021 00025 class LOG4CPP_EXPORT PatternLayout : public Layout { 00026 public: 00030 static const char* DEFAULT_CONVERSION_PATTERN; 00031 00035 static const char* SIMPLE_CONVERSION_PATTERN; 00036 00040 static const char* BASIC_CONVERSION_PATTERN; 00041 00046 static const char* TTCC_CONVERSION_PATTERN; 00047 00048 PatternLayout(); 00049 virtual ~PatternLayout(); 00050 00051 // NOTE: All double percentage signs ('%%') followed by a character 00052 // in the following comments should actually be a single char. 00053 // The doubles are included so that doxygen will print them correctly. 00059 virtual std::string format(const LoggingEvent& event); 00060 00087 virtual void setConversionPattern(const std::string& conversionPattern) 00088 throw(ConfigureFailure); 00089 00090 virtual std::string getConversionPattern() const; 00091 00092 virtual void clearConversionPattern(); 00093 00094 class LOG4CPP_EXPORT PatternComponent { 00095 public: 00096 inline virtual ~PatternComponent() {}; 00097 virtual void append(std::ostringstream& out, const LoggingEvent& event) = 0; 00098 }; 00099 00100 private: 00101 typedef std::vector<PatternComponent*> ComponentVector; 00102 ComponentVector _components; 00103 00104 std::string _conversionPattern; 00105 }; 00106 } 00107 00108 #endif // _LOG4CPP_PATTERNLAYOUT_HH