/src/logging-log4cxx/src/main/cpp/layout.cpp
Line | Count | Source |
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 | | #include <log4cxx/logstring.h> |
18 | | #include <log4cxx/layout.h> |
19 | | |
20 | | using namespace LOG4CXX_NS; |
21 | | using namespace LOG4CXX_NS::helpers; |
22 | | |
23 | | IMPLEMENT_LOG4CXX_OBJECT(Layout) |
24 | | |
25 | | |
26 | 1 | Layout::~Layout() {} |
27 | | |
28 | | LogString Layout::getContentType() const |
29 | 0 | { |
30 | 0 | return LOG4CXX_STR("text/plain"); |
31 | 0 | } |
32 | | |
33 | | #if LOG4CXX_ABI_VERSION <= 15 |
34 | | void Layout::format(LogString& output, const spi::LoggingEventPtr& event) const |
35 | 1 | { |
36 | 1 | Pool p; |
37 | 1 | format(output, event, p); |
38 | 1 | } |
39 | | |
40 | 0 | void Layout::appendHeader(LogString&, LOG4CXX_NS::helpers::Pool&) {} |
41 | | |
42 | | void Layout::appendHeader(LogString& output) |
43 | 0 | { |
44 | 0 | Pool p; |
45 | 0 | appendHeader(output, p); |
46 | 0 | } |
47 | | |
48 | 0 | void Layout::appendFooter(LogString&, LOG4CXX_NS::helpers::Pool&) {} |
49 | | |
50 | | void Layout::appendFooter(LogString& output) |
51 | 0 | { |
52 | 0 | Pool p; |
53 | 0 | appendFooter(output, p); |
54 | 0 | } |
55 | | #else |
56 | | void Layout::format(LogString& output, const spi::LoggingEventPtr& event, helpers::Pool&) const |
57 | | { |
58 | | format(output, event); |
59 | | } |
60 | | |
61 | | void Layout::appendHeader(LogString& output, helpers::Pool&) |
62 | | { |
63 | | appendHeader(output); |
64 | | } |
65 | | void Layout::appendHeader(LogString& output) |
66 | | { |
67 | | } |
68 | | |
69 | | void Layout::appendFooter(LogString& output, helpers::Pool&) |
70 | | { |
71 | | appendFooter(output); |
72 | | } |
73 | | void Layout::appendFooter(LogString& output) |
74 | | { |
75 | | } |
76 | | #endif |
77 | | |
78 | | /** |
79 | | * The expected length of a formatted event excluding the message text |
80 | | */ |
81 | | size_t Layout::getFormattedEventCharacterCount() const |
82 | 1 | { |
83 | 1 | auto exampleEvent = std::make_shared<spi::LoggingEvent> |
84 | 1 | ( LOG4CXX_STR("example.logger") |
85 | 1 | , Level::getDebug() |
86 | 1 | , LOG4CXX_LOCATION |
87 | 1 | , LogString() |
88 | 1 | ); |
89 | 1 | LogString text; |
90 | 1 | format(text, exampleEvent); |
91 | 1 | return text.size(); |
92 | 1 | } |
93 | | |
94 | | #if 15 < LOG4CXX_ABI_VERSION |
95 | | void Layout::activateOptions( LOG4CXX_ACTIVATE_OPTIONS_FORMAL_PARAMETERS ) |
96 | | { |
97 | | } |
98 | | #endif |