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 00084 virtual void setConversionPattern(const std::string& conversionPattern) 00085 throw(ConfigureFailure); 00086 00087 virtual std::string getConversionPattern() const; 00088 00089 virtual void clearConversionPattern(); 00090 00091 class LOG4CPP_EXPORT PatternComponent { 00092 public: 00093 inline virtual ~PatternComponent() {}; 00094 virtual void append(std::ostringstream& out, const LoggingEvent& event) = 0; 00095 }; 00096 00097 private: 00098 typedef std::vector<PatternComponent*> ComponentVector; 00099 ComponentVector _components; 00100 00101 std::string _conversionPattern; 00102 }; 00103 } 00104 00105 #endif // _LOG4CPP_PATTERNLAYOUT_HH