log4tango  5.0.2
PatternLayout.hh
Go to the documentation of this file.
1 //
2 // PatternLayout.hh
3 //
4 // Copyright (C) : 2000 - 2002
5 // LifeLine Networks BV (www.lifeline.nl). All rights reserved.
6 // Bastiaan Bakker. All rights reserved.
7 //
8 // 2004,2005,2006,2007,2008,2009,2010,2011,2012
9 // Synchrotron SOLEIL
10 // L'Orme des Merisiers
11 // Saint-Aubin - BP 48 - France
12 //
13 // This file is part of log4tango.
14 //
15 // Log4ango is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU Lesser General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 // Log4tango is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 // GNU Lesser General Public License for more details.
24 //
25 // You should have received a copy of the GNU Lesser General Public License
26 // along with Log4Tango. If not, see <http://www.gnu.org/licenses/>.
27 
28 #ifndef _LOG4TANGO_PATTERNLAYOUT_H
29 #define _LOG4TANGO_PATTERNLAYOUT_H
30 
31 #include <log4tango/Portability.hh>
32 #include <log4tango/Layout.hh>
33 #include <vector>
34 #ifdef LOG4TANGO_HAVE_SSTREAM
35 # include <sstream>
36 #endif
37 
38 namespace log4tango {
39 
40 //-----------------------------------------------------------------------------
41 // class : PatternLayout (a simple fixed format Layout implementation)
42 //-----------------------------------------------------------------------------
44 {
45 public:
46 
50  static const char* BASIC_CONVERSION_PATTERN;
51 
52  PatternLayout();
53 
54  virtual ~PatternLayout();
55 
56  // NOTE:
57  // All double percentage signs ('%%') followed by a character
58  // in the following comments should actually be a single char.
59  // The doubles are included so that doxygen will print them correctly.
60 
66  virtual std::string format(const LoggingEvent& event);
67 
93  virtual int set_conversion_pattern (const std::string& conversionPattern);
94 
95  virtual std::string get_conversion_pattern() const;
96 
97  virtual void clear_conversion_pattern();
98 
100  public:
101  inline virtual ~PatternComponent() {};
102  virtual void append(std::ostringstream& out, const LoggingEvent& event) = 0;
103  };
104 
105  private:
106  typedef std::vector<PatternComponent*> ComponentVector;
107  ComponentVector _components;
108  std::string _conversionPattern;
109 };
110 
111 } // namespace log4tango
112 
113 #endif // _LOG4TANGO_PATTERNLAYOUT_H
#define LOG4TANGO_EXPORT
Definition: Export.hh:38
Definition: Layout.hh:42
Definition: PatternLayout.hh:99
virtual ~PatternComponent()
Definition: PatternLayout.hh:101
virtual void append(std::ostringstream &out, const LoggingEvent &event)=0
Definition: PatternLayout.hh:44
static const char * BASIC_CONVERSION_PATTERN
A conversion pattern equivalent to the BasicLayout.
Definition: PatternLayout.hh:50
Definition: Portability.hh:56
Definition: Appender.hh:40
The internal representation of logging events.
Definition: LoggingEvent.hh:51