Coverage Report

Created: 2025-07-01 06:08

/src/logging-log4cxx/src/main/include/log4cxx/htmllayout.h
Line
Count
Source (jump to first uncovered line)
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
#include <log4cxx/layout.h>
22
#include <log4cxx/helpers/iso8601dateformat.h>
23
24
25
26
namespace LOG4CXX_NS
27
{
28
/**
29
This layout outputs events in a HTML table.
30
*/
31
class LOG4CXX_EXPORT HTMLLayout : public Layout
32
{
33
  private:
34
    LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(HTMLLayoutPrivate, m_priv)
35
36
  public:
37
    DECLARE_LOG4CXX_OBJECT(HTMLLayout)
38
0
    BEGIN_LOG4CXX_CAST_MAP()
39
0
    LOG4CXX_CAST_ENTRY(HTMLLayout)
40
0
    LOG4CXX_CAST_ENTRY_CHAIN(Layout)
41
0
    END_LOG4CXX_CAST_MAP()
42
43
    HTMLLayout();
44
    ~HTMLLayout();
45
46
    /**
47
    The <b>LocationInfo</b> option takes a boolean value. By
48
    default, it is set to false which means there will be no location
49
    information output by this layout. If the the option is set to
50
    true, then the file name and line number of the statement
51
    at the origin of the log statement will be output.
52
53
    <p>If you are embedding this layout within an
54
    {@link net::SMTPAppender SMTPAppender} then make sure
55
    to set the <b>LocationInfo</b> option of that appender as well.
56
    */
57
    void setLocationInfo(bool locationInfoFlag);
58
59
    /**
60
    Returns the current value of the <b>LocationInfo</b> option.
61
    */
62
    bool getLocationInfo() const;
63
64
    /**
65
    The <b>Title</b> option takes a String value. This option sets the
66
    document title of the generated HTML document.
67
    <p>Defaults to 'Log4cxx Log Messages'.
68
    */
69
    void setTitle(const LogString& title1);
70
71
    /**
72
    Returns the current value of the <b>Title</b> option.
73
    */
74
    const LogString& getTitle() const;
75
76
    /**
77
    Returns the content type output by this layout, i.e "text/html".
78
    */
79
    LogString getContentType() const override;
80
81
    /**
82
    \copybrief spi::OptionHandler::activateOptions()
83
84
    No action is performed in this implementation.
85
    */
86
0
    void activateOptions(helpers::Pool& /* p */) override {}
87
88
    /**
89
    \copybrief spi::OptionHandler::setOption()
90
91
    Supported options | Supported values | Default value
92
    -------------- | ---------------- | ---------------
93
    Title |  {any} | Log4cxx Log Messages
94
    LocationInfo | True,False | False
95
    */
96
    void setOption(const LogString& option, const LogString& value) override;
97
98
    void format(LogString& output,
99
      const spi::LoggingEventPtr& event, helpers::Pool& pool) const override;
100
101
    /**
102
    Append appropriate HTML headers.
103
    */
104
    void appendHeader(LogString& output, helpers::Pool& pool) override;
105
106
    /**
107
    Append the appropriate HTML footers.
108
    */
109
    void appendFooter(LogString& output, helpers::Pool& pool) override;
110
111
    /**
112
    The HTML layout handles the throwable contained in logging
113
    events. Hence, this method return <code>false</code>.  */
114
    bool ignoresThrowable() const override;
115
116
}; // class HtmlLayout
117
LOG4CXX_PTR_DEF(HTMLLayout);
118
}  // namespace log4cxx
119
120
#endif // _LOG4CXX_HTML_LAYOUT_H