/src/logging-log4cxx/src/main/include/log4cxx/layout.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_LAYOUT_H |
19 | | #define _LOG4CXX_LAYOUT_H |
20 | | |
21 | | #include <log4cxx/helpers/object.h> |
22 | | #include <log4cxx/spi/optionhandler.h> |
23 | | #include <log4cxx/spi/loggingevent.h> |
24 | | |
25 | | |
26 | | namespace LOG4CXX_NS |
27 | | { |
28 | | /** |
29 | | Extend this abstract class to create your own log layout format. |
30 | | */ |
31 | | class LOG4CXX_EXPORT Layout : |
32 | | public virtual spi::OptionHandler, |
33 | | public virtual helpers::Object |
34 | | { |
35 | | public: |
36 | | DECLARE_ABSTRACT_LOG4CXX_OBJECT(Layout) |
37 | 0 | BEGIN_LOG4CXX_CAST_MAP() |
38 | 0 | LOG4CXX_CAST_ENTRY(Layout) |
39 | 0 | LOG4CXX_CAST_ENTRY(spi::OptionHandler) |
40 | 0 | END_LOG4CXX_CAST_MAP() |
41 | | |
42 | | virtual ~Layout(); |
43 | | |
44 | | /** |
45 | | Implement this method to create your own layout format. |
46 | | */ |
47 | | virtual void format(LogString& output, |
48 | | const spi::LoggingEventPtr& event, LOG4CXX_NS::helpers::Pool& pool) const = 0; |
49 | | |
50 | | /** |
51 | | Returns the content type output by this layout. The base class |
52 | | returns "text/plain". |
53 | | */ |
54 | | virtual LogString getContentType() const; |
55 | | |
56 | | /** |
57 | | Append the header for the layout format. The base class does |
58 | | nothing. |
59 | | */ |
60 | | virtual void appendHeader(LogString& output, LOG4CXX_NS::helpers::Pool& p); |
61 | | |
62 | | /** |
63 | | Append the footer for the layout format. The base class does |
64 | | nothing. |
65 | | */ |
66 | | virtual void appendFooter(LogString& output, LOG4CXX_NS::helpers::Pool& p); |
67 | | |
68 | | /** |
69 | | If the layout handles the throwable object contained within |
70 | | {@link spi::LoggingEvent LoggingEvent}, then the layout should return |
71 | | <code>false</code>. Otherwise, if the layout ignores throwable |
72 | | object, then the layout should return <code>true</code>. |
73 | | |
74 | | <p>The SimpleLayout, FMTLayout and PatternLayout return <code>true</code>. |
75 | | The other layouts return <code>false</code>. |
76 | | */ |
77 | | virtual bool ignoresThrowable() const = 0; |
78 | | |
79 | | protected: |
80 | | /** |
81 | | * The expected length of a formatted event excluding the message text |
82 | | */ |
83 | | size_t getFormattedEventCharacterCount() const; |
84 | | }; |
85 | | LOG4CXX_PTR_DEF(Layout); |
86 | | } |
87 | | |
88 | | #endif // _LOG4CXX_LAYOUT_H |