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>
|
---|
28 | #include <log4cxx/helpers/iso8601dateformat.h>
|
---|
29 |
|
---|
30 |
|
---|
31 |
|
---|
32 | namespace log4cxx
|
---|
33 | {
|
---|
34 | /**
|
---|
35 | This layout outputs events in a HTML table.
|
---|
36 | */
|
---|
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:
|
---|
48 | DECLARE_LOG4CXX_OBJECT(HTMLLayout)
|
---|
49 | BEGIN_LOG4CXX_CAST_MAP()
|
---|
50 | LOG4CXX_CAST_ENTRY(HTMLLayout)
|
---|
51 | LOG4CXX_CAST_ENTRY_CHAIN(Layout)
|
---|
52 | END_LOG4CXX_CAST_MAP()
|
---|
53 |
|
---|
54 | HTMLLayout();
|
---|
55 |
|
---|
56 | /**
|
---|
57 | The <b>LocationInfo</b> option takes a boolean value. By
|
---|
58 | default, it is set to false which means there will be no location
|
---|
59 | information output by this layout. If the the option is set to
|
---|
60 | true, then the file name and line number of the statement
|
---|
61 | at the origin of the log statement will be output.
|
---|
62 |
|
---|
63 | <p>If you are embedding this layout within an
|
---|
64 | {@link net::SMTPAppender SMTPAppender} then make sure
|
---|
65 | to set the <b>LocationInfo</b> option of that appender as well.
|
---|
66 | */
|
---|
67 | inline void setLocationInfo(bool locationInfoFlag)
|
---|
68 | { this->locationInfo = locationInfoFlag; }
|
---|
69 |
|
---|
70 | /**
|
---|
71 | Returns the current value of the <b>LocationInfo</b> option.
|
---|
72 | */
|
---|
73 | inline bool getLocationInfo() const
|
---|
74 | { return locationInfo; }
|
---|
75 |
|
---|
76 | /**
|
---|
77 | The <b>Title</b> option takes a String value. This option sets the
|
---|
78 | document title of the generated HTML document.
|
---|
79 | <p>Defaults to 'Log4cxx Log Messages'.
|
---|
80 | */
|
---|
81 | inline void setTitle(const LogString& title1)
|
---|
82 | { this->title.assign(title1); }
|
---|
83 |
|
---|
84 | /**
|
---|
85 | Returns the current value of the <b>Title</b> option.
|
---|
86 | */
|
---|
87 | inline const LogString& getTitle() const
|
---|
88 | { return title; }
|
---|
89 |
|
---|
90 | /**
|
---|
91 | Returns the content type output by this layout, i.e "text/html".
|
---|
92 | */
|
---|
93 | virtual LogString getContentType() const { return LOG4CXX_STR("text/html"); }
|
---|
94 |
|
---|
95 | /**
|
---|
96 | No options to activate.
|
---|
97 | */
|
---|
98 | virtual void activateOptions(log4cxx::helpers::Pool& /* p */) {}
|
---|
99 |
|
---|
100 | /**
|
---|
101 | Set options
|
---|
102 | */
|
---|
103 | virtual void setOption(const LogString& option, const LogString& value);
|
---|
104 |
|
---|
105 | virtual void format(LogString& output,
|
---|
106 | const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool) const;
|
---|
107 |
|
---|
108 | /**
|
---|
109 | Append appropriate HTML headers.
|
---|
110 | */
|
---|
111 | virtual void appendHeader(LogString& output, log4cxx::helpers::Pool& pool);
|
---|
112 |
|
---|
113 | /**
|
---|
114 | Append the appropriate HTML footers.
|
---|
115 | */
|
---|
116 | virtual void appendFooter(LogString& output, log4cxx::helpers::Pool& pool);
|
---|
117 |
|
---|
118 | /**
|
---|
119 | The HTML layout handles the throwable contained in logging
|
---|
120 | events. Hence, this method return <code>false</code>. */
|
---|
121 | virtual bool ignoresThrowable() const
|
---|
122 | { return false; }
|
---|
123 |
|
---|
124 | }; // class HtmlLayout
|
---|
125 | LOG4CXX_PTR_DEF(HTMLLayout);
|
---|
126 | } // namespace log4cxx
|
---|
127 |
|
---|
128 | #if defined(_MSC_VER)
|
---|
129 | #pragma warning ( pop )
|
---|
130 | #endif
|
---|
131 |
|
---|
132 |
|
---|
133 | #endif // _LOG4CXX_HTML_LAYOUT_H
|
---|