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 "Base/GCException.h" 00013 #include <log4cpp/Portability.hh> 00014 #include <log4cpp/Layout.hh> 00015 #include <log4cpp/Configurator.hh> 00016 #include <vector> 00017 #ifdef LOG4CPP_HAVE_SSTREAM 00018 #include <sstream> 00019 #endif 00020 00021 LOG4CPP_NS_BEGIN 00022 00026 class LOG4CPP_EXPORT PatternLayout : public Layout { 00027 public: 00031 static const char* DEFAULT_CONVERSION_PATTERN; 00032 00036 static const char* SIMPLE_CONVERSION_PATTERN; 00037 00041 static const char* BASIC_CONVERSION_PATTERN; 00042 00047 static const char* TTCC_CONVERSION_PATTERN; 00048 00049 PatternLayout(); 00050 virtual ~PatternLayout(); 00051 00052 // NOTE: All double percentage signs ('%%') followed by a character 00053 // in the following comments should actually be a single char. 00054 // The doubles are included so that doxygen will print them correctly. 00060 virtual std::string format(const LoggingEvent& event); 00061 00085 virtual void setConversionPattern(const std::string& conversionPattern); 00086 //throw (GenICam::InvalidArgumentException); 00087 00088 virtual void setConversionPattern(const char* conversionPattern); 00089 //throw (GenICam::InvalidArgumentException); 00090 00091 virtual std::string getConversionPattern() const; 00092 00093 virtual void clearConversionPattern(); 00094 00095 class LOG4CPP_EXPORT PatternComponent { 00096 public: 00097 inline virtual ~PatternComponent() {}; 00098 virtual void append(std::ostringstream& out, const LoggingEvent& event) = 0; 00099 }; 00100 00101 private: 00102 typedef std::vector<PatternComponent*> ComponentVector; 00103 ComponentVector _components; 00104 00105 std::string _conversionPattern; 00106 }; 00107 LOG4CPP_NS_END 00108 00109 #endif // _LOG4CPP_PATTERNLAYOUT_HH