Apache log4cxx  Version 0.12.1
htmllayout.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _LOG4CXX_HTML_LAYOUT_H
19 #define _LOG4CXX_HTML_LAYOUT_H
20 
21 #if defined(_MSC_VER)
22  #pragma warning ( push )
23  #pragma warning ( disable: 4231 4251 4275 4786 )
24 #endif
25 
26 
27 #include <log4cxx/layout.h>
29 
30 
31 
32 namespace log4cxx
33 {
37 class LOG4CXX_EXPORT HTMLLayout : public Layout
38 {
39  private:
40  // Print no location info by default
41  bool locationInfo; //= false
42 
43  LogString title;
44 
45  helpers::ISO8601DateFormat dateFormat;
46 
47  public:
53 
54  HTMLLayout();
55 
67  inline void setLocationInfo(bool locationInfoFlag)
68  {
69  this->locationInfo = locationInfoFlag;
70  }
71 
75  inline bool getLocationInfo() const
76  {
77  return locationInfo;
78  }
79 
85  inline void setTitle(const LogString& title1)
86  {
87  this->title.assign(title1);
88  }
89 
93  inline const LogString& getTitle() const
94  {
95  return title;
96  }
97 
101  virtual LogString getContentType() const
102  {
103  return LOG4CXX_STR("text/html");
104  }
105 
109  virtual void activateOptions(log4cxx::helpers::Pool& /* p */) {}
110 
114  virtual void setOption(const LogString& option, const LogString& value);
115 
116  virtual void format(LogString& output,
117  const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool) const;
118 
122  virtual void appendHeader(LogString& output, log4cxx::helpers::Pool& pool);
123 
127  virtual void appendFooter(LogString& output, log4cxx::helpers::Pool& pool);
128 
132  virtual bool ignoresThrowable() const
133  {
134  return false;
135  }
136 
137 }; // class HtmlLayout
139 } // namespace log4cxx
140 
141 #if defined(_MSC_VER)
142  #pragma warning ( pop )
143 #endif
144 
145 
146 #endif // _LOG4CXX_HTML_LAYOUT_H
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:148
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:142
virtual void activateOptions(log4cxx::helpers::Pool &)
No options to activate.
Definition: htmllayout.h:109
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:37
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:136
Extend this abstract class to create your own log layout format.
Definition: layout.h:37
const LogString & getTitle() const
Returns the current value of the Title option.
Definition: htmllayout.h:93
LOG4CXX_PTR_DEF(Appender)
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:39
Definition: pool.h:32
virtual LogString getContentType() const
Returns the content type output by this layout, i.e "text/html".
Definition: htmllayout.h:101
virtual bool ignoresThrowable() const
The HTML layout handles the throwable contained in logging events.
Definition: htmllayout.h:132
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:154
This layout outputs events in a HTML table.
Definition: htmllayout.h:37
void setLocationInfo(bool locationInfoFlag)
The LocationInfo option takes a boolean value.
Definition: htmllayout.h:67
Formats a date in the format yyyy-MM-dd HH:mm:ss,SSS for example "1999-11-27 15:49:37,459".
Definition: iso8601dateformat.h:36
bool getLocationInfo() const
Returns the current value of the LocationInfo option.
Definition: htmllayout.h:75
void setTitle(const LogString &title1)
The Title option takes a String value.
Definition: htmllayout.h:85
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66