/src/logging-log4cxx/src/main/cpp/jsonlayout.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 | | |
18 | | #include <log4cxx/logstring.h> |
19 | | #include <log4cxx/jsonlayout.h> |
20 | | #include <log4cxx/spi/loggingevent.h> |
21 | | #include <log4cxx/level.h> |
22 | | #include <log4cxx/helpers/optionconverter.h> |
23 | | #include <log4cxx/helpers/cacheddateformat.h> |
24 | | #include <log4cxx/helpers/simpledateformat.h> |
25 | | #include <log4cxx/helpers/stringhelper.h> |
26 | | #include <log4cxx/helpers/transcoder.h> |
27 | | #include <log4cxx/private/layout_priv.h> |
28 | | |
29 | | #include <string.h> |
30 | | |
31 | | using namespace LOG4CXX_NS; |
32 | | using namespace LOG4CXX_NS::helpers; |
33 | | using namespace LOG4CXX_NS::spi; |
34 | | |
35 | | IMPLEMENT_LOG4CXX_OBJECT(JSONLayout) |
36 | | |
37 | | struct JSONLayout::JSONLayoutPrivate |
38 | | { |
39 | | JSONLayoutPrivate() : |
40 | 4.79k | locationInfo(false), |
41 | 4.79k | prettyPrint(false), |
42 | 4.79k | ppIndentL1(LOG4CXX_STR(" ")), |
43 | 4.79k | ppIndentL2(LOG4CXX_STR(" ")), |
44 | 4.79k | expectedPatternLength(100), |
45 | 4.79k | threadInfo(false) {} |
46 | | |
47 | | // Print no location info by default |
48 | | bool locationInfo; //= false |
49 | | bool prettyPrint; //= false |
50 | | |
51 | | pattern::CachedDateFormat dateFormat |
52 | | { std::make_shared<helpers::SimpleDateFormat>(LOG4CXX_STR("yyyy-MM-dd HH:mm:ss,SSS")) |
53 | | , pattern::CachedDateFormat::getMaximumCacheValidity(LOG4CXX_STR("yyyy-MM-dd HH:mm:ss,SSS")) |
54 | | }; |
55 | | |
56 | | LogString ppIndentL1; |
57 | | LogString ppIndentL2; |
58 | | |
59 | | // Expected length of a formatted event excluding the message text |
60 | | size_t expectedPatternLength; |
61 | | |
62 | | // Thread info is not included by default |
63 | | bool threadInfo; //= false |
64 | | }; |
65 | | |
66 | | JSONLayout::JSONLayout() : |
67 | 4.79k | m_priv(std::make_unique<JSONLayoutPrivate>()) |
68 | 4.79k | { |
69 | 4.79k | } Unexecuted instantiation: log4cxx::JSONLayout::JSONLayout() log4cxx::JSONLayout::JSONLayout() Line | Count | Source | 67 | 4.79k | m_priv(std::make_unique<JSONLayoutPrivate>()) | 68 | 4.79k | { | 69 | 4.79k | } |
|
70 | | |
71 | 4.79k | JSONLayout::~JSONLayout(){} |
72 | | |
73 | | void JSONLayout::setLocationInfo(bool locationInfoFlag) |
74 | 2.69k | { |
75 | 2.69k | m_priv->locationInfo = locationInfoFlag; |
76 | 2.69k | } |
77 | | |
78 | | bool JSONLayout::getLocationInfo() const |
79 | 0 | { |
80 | 0 | return m_priv->locationInfo; |
81 | 0 | } |
82 | | |
83 | | void JSONLayout::setPrettyPrint(bool prettyPrintFlag) |
84 | 2.27k | { |
85 | 2.27k | m_priv->prettyPrint = prettyPrintFlag; |
86 | 2.27k | } |
87 | | |
88 | | bool JSONLayout::getPrettyPrint() const |
89 | 0 | { |
90 | 0 | return m_priv->prettyPrint; |
91 | 0 | } |
92 | | |
93 | | void JSONLayout::setThreadInfo(bool newValue) |
94 | 2.50k | { |
95 | 2.50k | m_priv->threadInfo = newValue; |
96 | 2.50k | } |
97 | | |
98 | | bool JSONLayout::getThreadInfo() const |
99 | 0 | { |
100 | 0 | return m_priv->threadInfo; |
101 | 0 | } |
102 | | |
103 | | LogString JSONLayout::getContentType() const |
104 | 0 | { |
105 | 0 | return LOG4CXX_STR("application/json"); |
106 | 0 | } |
107 | | |
108 | | void JSONLayout::activateOptions( LOG4CXX_ACTIVATE_OPTIONS_FORMAL_PARAMETERS ) |
109 | 0 | { |
110 | 0 | m_priv->expectedPatternLength = priv::doubledLayoutSize(getFormattedEventCharacterCount()); |
111 | 0 | } |
112 | | |
113 | | void JSONLayout::setOption(const LogString& option, const LogString& value) |
114 | 7.46k | { |
115 | 7.46k | if (StringHelper::equalsIgnoreCase(option, |
116 | 7.46k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) |
117 | 2.69k | { |
118 | 2.69k | setLocationInfo(OptionConverter::toBoolean(value, false)); |
119 | 2.69k | } |
120 | 4.77k | else if (StringHelper::equalsIgnoreCase(option, |
121 | 4.77k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) |
122 | 2.50k | { |
123 | 2.50k | setThreadInfo(OptionConverter::toBoolean(value, false)); |
124 | 2.50k | } |
125 | 2.27k | else if (StringHelper::equalsIgnoreCase(option, |
126 | 2.27k | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) |
127 | 2.27k | { |
128 | 2.27k | setPrettyPrint(OptionConverter::toBoolean(value, false)); |
129 | 2.27k | } |
130 | 7.46k | } log4cxx::JSONLayout::setOption(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 114 | 3.17k | { | 115 | 3.17k | if (StringHelper::equalsIgnoreCase(option, | 116 | 3.17k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) | 117 | 1.18k | { | 118 | 1.18k | setLocationInfo(OptionConverter::toBoolean(value, false)); | 119 | 1.18k | } | 120 | 1.99k | else if (StringHelper::equalsIgnoreCase(option, | 121 | 1.99k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) | 122 | 1.03k | { | 123 | 1.03k | setThreadInfo(OptionConverter::toBoolean(value, false)); | 124 | 1.03k | } | 125 | 960 | else if (StringHelper::equalsIgnoreCase(option, | 126 | 960 | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) | 127 | 960 | { | 128 | 960 | setPrettyPrint(OptionConverter::toBoolean(value, false)); | 129 | 960 | } | 130 | 3.17k | } |
log4cxx::JSONLayout::setOption(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) Line | Count | Source | 114 | 4.28k | { | 115 | 4.28k | if (StringHelper::equalsIgnoreCase(option, | 116 | 4.28k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) | 117 | 1.50k | { | 118 | 1.50k | setLocationInfo(OptionConverter::toBoolean(value, false)); | 119 | 1.50k | } | 120 | 2.78k | else if (StringHelper::equalsIgnoreCase(option, | 121 | 2.78k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) | 122 | 1.47k | { | 123 | 1.47k | setThreadInfo(OptionConverter::toBoolean(value, false)); | 124 | 1.47k | } | 125 | 1.31k | else if (StringHelper::equalsIgnoreCase(option, | 126 | 1.31k | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) | 127 | 1.31k | { | 128 | 1.31k | setPrettyPrint(OptionConverter::toBoolean(value, false)); | 129 | 1.31k | } | 130 | 4.28k | } |
|
131 | | |
132 | | void JSONLayout::format( LOG4CXX_FORMAT_LAYOUT_FORMAL_PARAMETERS ) const |
133 | 4.79k | { |
134 | 4.79k | auto& lsMsg = event->getRenderedMessage(); |
135 | 4.79k | priv::reserveFormattedEvent(output, m_priv->expectedPatternLength, lsMsg.size()); |
136 | 4.79k | output.append(LOG4CXX_STR("{")); |
137 | 4.79k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
138 | | |
139 | 4.79k | if (m_priv->prettyPrint) |
140 | 2.27k | { |
141 | 2.27k | output.append(m_priv->ppIndentL1); |
142 | 2.27k | } |
143 | | |
144 | 4.79k | output.append(LOG4CXX_STR("\"timestamp\": \"")); |
145 | 4.79k | m_priv->dateFormat.format(output, event->getTimeStamp()); |
146 | 4.79k | output.append(LOG4CXX_STR("\",")); |
147 | 4.79k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
148 | | |
149 | 4.79k | if (m_priv->threadInfo) |
150 | 2.50k | { |
151 | 2.50k | if (m_priv->prettyPrint) |
152 | 1.57k | { |
153 | 1.57k | output.append(m_priv->ppIndentL1); |
154 | 1.57k | } |
155 | 2.50k | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); |
156 | 2.50k | output.append(LOG4CXX_STR(": ")); |
157 | 2.50k | appendQuotedEscapedString(output, event->getThreadName()); |
158 | 2.50k | output.append(LOG4CXX_STR(",")); |
159 | 2.50k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
160 | 2.50k | } |
161 | | |
162 | 4.79k | if (m_priv->prettyPrint) |
163 | 2.27k | { |
164 | 2.27k | output.append(m_priv->ppIndentL1); |
165 | 2.27k | } |
166 | | |
167 | 4.79k | output.append(LOG4CXX_STR("\"level\": ")); |
168 | 4.79k | LogString level; |
169 | 4.79k | event->getLevel()->toString(level); |
170 | 4.79k | appendQuotedEscapedString(output, level); |
171 | 4.79k | output.append(LOG4CXX_STR(",")); |
172 | 4.79k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
173 | | |
174 | 4.79k | if (m_priv->prettyPrint) |
175 | 2.27k | { |
176 | 2.27k | output.append(m_priv->ppIndentL1); |
177 | 2.27k | } |
178 | | |
179 | 4.79k | output.append(LOG4CXX_STR("\"logger\": ")); |
180 | 4.79k | appendQuotedEscapedString(output, event->getLoggerName()); |
181 | 4.79k | output.append(LOG4CXX_STR(",")); |
182 | 4.79k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
183 | | |
184 | 4.79k | if (m_priv->prettyPrint) |
185 | 2.27k | { |
186 | 2.27k | output.append(m_priv->ppIndentL1); |
187 | 2.27k | } |
188 | | |
189 | 4.79k | output.append(LOG4CXX_STR("\"message\": ")); |
190 | 4.79k | appendQuotedEscapedString(output, lsMsg); |
191 | | |
192 | 4.79k | appendSerializedMDC(output, event); |
193 | 4.79k | appendSerializedNDC(output, event); |
194 | | |
195 | 4.79k | if (m_priv->locationInfo) |
196 | 2.69k | { |
197 | 2.69k | output.append(LOG4CXX_STR(",")); |
198 | 2.69k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
199 | 2.69k | appendSerializedLocationInfo(output, event); |
200 | 2.69k | } |
201 | | |
202 | 4.79k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
203 | 4.79k | output.append(LOG4CXX_STR("}")); |
204 | 4.79k | output.append(LOG4CXX_EOL); |
205 | 4.79k | } log4cxx::JSONLayout::format(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&, log4cxx::helpers::Pool&) const Line | Count | Source | 133 | 2.07k | { | 134 | 2.07k | auto& lsMsg = event->getRenderedMessage(); | 135 | 2.07k | priv::reserveFormattedEvent(output, m_priv->expectedPatternLength, lsMsg.size()); | 136 | 2.07k | output.append(LOG4CXX_STR("{")); | 137 | 2.07k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 138 | | | 139 | 2.07k | if (m_priv->prettyPrint) | 140 | 960 | { | 141 | 960 | output.append(m_priv->ppIndentL1); | 142 | 960 | } | 143 | | | 144 | 2.07k | output.append(LOG4CXX_STR("\"timestamp\": \"")); | 145 | 2.07k | m_priv->dateFormat.format(output, event->getTimeStamp()); | 146 | 2.07k | output.append(LOG4CXX_STR("\",")); | 147 | 2.07k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 148 | | | 149 | 2.07k | if (m_priv->threadInfo) | 150 | 1.03k | { | 151 | 1.03k | if (m_priv->prettyPrint) | 152 | 627 | { | 153 | 627 | output.append(m_priv->ppIndentL1); | 154 | 627 | } | 155 | 1.03k | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); | 156 | 1.03k | output.append(LOG4CXX_STR(": ")); | 157 | 1.03k | appendQuotedEscapedString(output, event->getThreadName()); | 158 | 1.03k | output.append(LOG4CXX_STR(",")); | 159 | 1.03k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 160 | 1.03k | } | 161 | | | 162 | 2.07k | if (m_priv->prettyPrint) | 163 | 960 | { | 164 | 960 | output.append(m_priv->ppIndentL1); | 165 | 960 | } | 166 | | | 167 | 2.07k | output.append(LOG4CXX_STR("\"level\": ")); | 168 | 2.07k | LogString level; | 169 | 2.07k | event->getLevel()->toString(level); | 170 | 2.07k | appendQuotedEscapedString(output, level); | 171 | 2.07k | output.append(LOG4CXX_STR(",")); | 172 | 2.07k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 173 | | | 174 | 2.07k | if (m_priv->prettyPrint) | 175 | 960 | { | 176 | 960 | output.append(m_priv->ppIndentL1); | 177 | 960 | } | 178 | | | 179 | 2.07k | output.append(LOG4CXX_STR("\"logger\": ")); | 180 | 2.07k | appendQuotedEscapedString(output, event->getLoggerName()); | 181 | 2.07k | output.append(LOG4CXX_STR(",")); | 182 | 2.07k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 183 | | | 184 | 2.07k | if (m_priv->prettyPrint) | 185 | 960 | { | 186 | 960 | output.append(m_priv->ppIndentL1); | 187 | 960 | } | 188 | | | 189 | 2.07k | output.append(LOG4CXX_STR("\"message\": ")); | 190 | 2.07k | appendQuotedEscapedString(output, lsMsg); | 191 | | | 192 | 2.07k | appendSerializedMDC(output, event); | 193 | 2.07k | appendSerializedNDC(output, event); | 194 | | | 195 | 2.07k | if (m_priv->locationInfo) | 196 | 1.18k | { | 197 | 1.18k | output.append(LOG4CXX_STR(",")); | 198 | 1.18k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 199 | 1.18k | appendSerializedLocationInfo(output, event); | 200 | 1.18k | } | 201 | | | 202 | 2.07k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 203 | 2.07k | output.append(LOG4CXX_STR("}")); | 204 | 2.07k | output.append(LOG4CXX_EOL); | 205 | 2.07k | } |
log4cxx::JSONLayout::format(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&, std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&, log4cxx::helpers::Pool&) const Line | Count | Source | 133 | 2.71k | { | 134 | 2.71k | auto& lsMsg = event->getRenderedMessage(); | 135 | 2.71k | priv::reserveFormattedEvent(output, m_priv->expectedPatternLength, lsMsg.size()); | 136 | 2.71k | output.append(LOG4CXX_STR("{")); | 137 | 2.71k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 138 | | | 139 | 2.71k | if (m_priv->prettyPrint) | 140 | 1.31k | { | 141 | 1.31k | output.append(m_priv->ppIndentL1); | 142 | 1.31k | } | 143 | | | 144 | 2.71k | output.append(LOG4CXX_STR("\"timestamp\": \"")); | 145 | 2.71k | m_priv->dateFormat.format(output, event->getTimeStamp()); | 146 | 2.71k | output.append(LOG4CXX_STR("\",")); | 147 | 2.71k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 148 | | | 149 | 2.71k | if (m_priv->threadInfo) | 150 | 1.47k | { | 151 | 1.47k | if (m_priv->prettyPrint) | 152 | 951 | { | 153 | 951 | output.append(m_priv->ppIndentL1); | 154 | 951 | } | 155 | 1.47k | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); | 156 | 1.47k | output.append(LOG4CXX_STR(": ")); | 157 | 1.47k | appendQuotedEscapedString(output, event->getThreadName()); | 158 | 1.47k | output.append(LOG4CXX_STR(",")); | 159 | 1.47k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 160 | 1.47k | } | 161 | | | 162 | 2.71k | if (m_priv->prettyPrint) | 163 | 1.31k | { | 164 | 1.31k | output.append(m_priv->ppIndentL1); | 165 | 1.31k | } | 166 | | | 167 | 2.71k | output.append(LOG4CXX_STR("\"level\": ")); | 168 | 2.71k | LogString level; | 169 | 2.71k | event->getLevel()->toString(level); | 170 | 2.71k | appendQuotedEscapedString(output, level); | 171 | 2.71k | output.append(LOG4CXX_STR(",")); | 172 | 2.71k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 173 | | | 174 | 2.71k | if (m_priv->prettyPrint) | 175 | 1.31k | { | 176 | 1.31k | output.append(m_priv->ppIndentL1); | 177 | 1.31k | } | 178 | | | 179 | 2.71k | output.append(LOG4CXX_STR("\"logger\": ")); | 180 | 2.71k | appendQuotedEscapedString(output, event->getLoggerName()); | 181 | 2.71k | output.append(LOG4CXX_STR(",")); | 182 | 2.71k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 183 | | | 184 | 2.71k | if (m_priv->prettyPrint) | 185 | 1.31k | { | 186 | 1.31k | output.append(m_priv->ppIndentL1); | 187 | 1.31k | } | 188 | | | 189 | 2.71k | output.append(LOG4CXX_STR("\"message\": ")); | 190 | 2.71k | appendQuotedEscapedString(output, lsMsg); | 191 | | | 192 | 2.71k | appendSerializedMDC(output, event); | 193 | 2.71k | appendSerializedNDC(output, event); | 194 | | | 195 | 2.71k | if (m_priv->locationInfo) | 196 | 1.50k | { | 197 | 1.50k | output.append(LOG4CXX_STR(",")); | 198 | 1.50k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 199 | 1.50k | appendSerializedLocationInfo(output, event); | 200 | 1.50k | } | 201 | | | 202 | 2.71k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 203 | 2.71k | output.append(LOG4CXX_STR("}")); | 204 | 2.71k | output.append(LOG4CXX_EOL); | 205 | 2.71k | } |
|
206 | | |
207 | | void JSONLayout::appendQuotedEscapedString(LogString& buf, |
208 | | const LogString& input) const |
209 | 71.6k | { |
210 | 71.6k | appendItem(input, buf); |
211 | 71.6k | } log4cxx::JSONLayout::appendQuotedEscapedString(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const Line | Count | Source | 209 | 31.2k | { | 210 | 31.2k | appendItem(input, buf); | 211 | 31.2k | } |
log4cxx::JSONLayout::appendQuotedEscapedString(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) const Line | Count | Source | 209 | 40.4k | { | 210 | 40.4k | appendItem(input, buf); | 211 | 40.4k | } |
|
212 | | |
213 | | void JSONLayout::appendItem(const LogString& input, LogString& buf) |
214 | 71.6k | { |
215 | 71.6k | auto toHexDigit = [](int ch) -> int |
216 | 3.84M | { |
217 | 3.84M | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; |
218 | 3.84M | }; jsonlayout.cpp:log4cxx::JSONLayout::appendItem(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&)::$_0::operator()(int) const Line | Count | Source | 216 | 1.35M | { | 217 | 1.35M | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 1.35M | }; |
jsonlayout.cpp:log4cxx::JSONLayout::appendItem(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&)::$_0::operator()(int) const Line | Count | Source | 216 | 2.48M | { | 217 | 2.48M | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 2.48M | }; |
|
219 | | /* add leading quote */ |
220 | 71.6k | buf.push_back(0x22); |
221 | | |
222 | 71.6k | auto start = input.begin(); |
223 | 1.91M | for (auto nextCodePoint = start; input.end() != nextCodePoint; ) |
224 | 1.84M | { |
225 | 1.84M | auto lastCodePoint = nextCodePoint; |
226 | 1.84M | auto ch = Transcoder::decode(input, nextCodePoint); |
227 | 1.84M | if (nextCodePoint == lastCodePoint) // failed to decode input? |
228 | 1.55k | { |
229 | 1.55k | nextCodePoint = input.end(); |
230 | 1.55k | ch = 0xFFFD; // The Unicode replacement character |
231 | 1.55k | } |
232 | 1.83M | else if ((0xD800 <= ch && ch <= 0xDFFF) || 0x10FFFF < ch) |
233 | 0 | { |
234 | 0 | ch = 0xFFFD; // The Unicode replacement character |
235 | 0 | } |
236 | 1.83M | else if (0x22 == ch || 0x5c == ch) // double quote or backslash? |
237 | 16.7k | ; |
238 | 1.82M | else if (0x20 <= ch) // not a control character? |
239 | 775k | continue; |
240 | | |
241 | 1.06M | if (start != lastCodePoint) |
242 | 33.2k | buf.append(start, lastCodePoint); |
243 | 1.06M | start = nextCodePoint; |
244 | 1.06M | switch (ch) |
245 | 1.06M | { |
246 | 27.8k | case 0x08: |
247 | | /* \b backspace */ |
248 | 27.8k | buf.push_back(0x5c); |
249 | 27.8k | buf.push_back('b'); |
250 | 27.8k | break; |
251 | | |
252 | 4.22k | case 0x09: |
253 | | /* \t tab */ |
254 | 4.22k | buf.push_back(0x5c); |
255 | 4.22k | buf.push_back('t'); |
256 | 4.22k | break; |
257 | | |
258 | 18.4k | case 0x0a: |
259 | | /* \n newline */ |
260 | 18.4k | buf.push_back(0x5c); |
261 | 18.4k | buf.push_back('n'); |
262 | 18.4k | break; |
263 | | |
264 | 23.2k | case 0x0c: |
265 | | /* \f form feed */ |
266 | 23.2k | buf.push_back(0x5c); |
267 | 23.2k | buf.push_back('f'); |
268 | 23.2k | break; |
269 | | |
270 | 14.3k | case 0x0d: |
271 | | /* \r carriage return */ |
272 | 14.3k | buf.push_back(0x5c); |
273 | 14.3k | buf.push_back('r'); |
274 | 14.3k | break; |
275 | | |
276 | 10.2k | case 0x22: |
277 | | /* \" double quote */ |
278 | 10.2k | buf.push_back(0x5c); |
279 | 10.2k | buf.push_back(0x22); |
280 | 10.2k | break; |
281 | | |
282 | 6.49k | case 0x5c: |
283 | | /* \\ backslash */ |
284 | 6.49k | buf.push_back(0x5c); |
285 | 6.49k | buf.push_back(0x5c); |
286 | 6.49k | break; |
287 | | |
288 | 960k | default: |
289 | 960k | buf.push_back(0x5c); |
290 | 960k | buf.push_back(0x75); // 'u' |
291 | 960k | buf.push_back(toHexDigit((ch & 0xF000) >> 12)); |
292 | 960k | buf.push_back(toHexDigit((ch & 0xF00) >> 8)); |
293 | 960k | buf.push_back(toHexDigit((ch & 0xF0) >> 4)); |
294 | 960k | buf.push_back(toHexDigit(ch & 0xF)); |
295 | 960k | break; |
296 | 1.06M | } |
297 | 1.06M | } |
298 | 71.6k | buf.append(start, input.end()); |
299 | | |
300 | | /* add trailing quote */ |
301 | 71.6k | buf.push_back(0x22); |
302 | 71.6k | } log4cxx::JSONLayout::appendItem(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Line | Count | Source | 214 | 31.2k | { | 215 | 31.2k | auto toHexDigit = [](int ch) -> int | 216 | 31.2k | { | 217 | 31.2k | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 31.2k | }; | 219 | | /* add leading quote */ | 220 | 31.2k | buf.push_back(0x22); | 221 | | | 222 | 31.2k | auto start = input.begin(); | 223 | 630k | for (auto nextCodePoint = start; input.end() != nextCodePoint; ) | 224 | 599k | { | 225 | 599k | auto lastCodePoint = nextCodePoint; | 226 | 599k | auto ch = Transcoder::decode(input, nextCodePoint); | 227 | 599k | if (nextCodePoint == lastCodePoint) // failed to decode input? | 228 | 1.55k | { | 229 | 1.55k | nextCodePoint = input.end(); | 230 | 1.55k | ch = 0xFFFD; // The Unicode replacement character | 231 | 1.55k | } | 232 | 598k | else if ((0xD800 <= ch && ch <= 0xDFFF) || 0x10FFFF < ch) | 233 | 0 | { | 234 | 0 | ch = 0xFFFD; // The Unicode replacement character | 235 | 0 | } | 236 | 598k | else if (0x22 == ch || 0x5c == ch) // double quote or backslash? | 237 | 3.63k | ; | 238 | 594k | else if (0x20 <= ch) // not a control character? | 239 | 250k | continue; | 240 | | | 241 | 349k | if (start != lastCodePoint) | 242 | 7.27k | buf.append(start, lastCodePoint); | 243 | 349k | start = nextCodePoint; | 244 | 349k | switch (ch) | 245 | 349k | { | 246 | 1.12k | case 0x08: | 247 | | /* \b backspace */ | 248 | 1.12k | buf.push_back(0x5c); | 249 | 1.12k | buf.push_back('b'); | 250 | 1.12k | break; | 251 | | | 252 | 385 | case 0x09: | 253 | | /* \t tab */ | 254 | 385 | buf.push_back(0x5c); | 255 | 385 | buf.push_back('t'); | 256 | 385 | break; | 257 | | | 258 | 3.66k | case 0x0a: | 259 | | /* \n newline */ | 260 | 3.66k | buf.push_back(0x5c); | 261 | 3.66k | buf.push_back('n'); | 262 | 3.66k | break; | 263 | | | 264 | 483 | case 0x0c: | 265 | | /* \f form feed */ | 266 | 483 | buf.push_back(0x5c); | 267 | 483 | buf.push_back('f'); | 268 | 483 | break; | 269 | | | 270 | 1.38k | case 0x0d: | 271 | | /* \r carriage return */ | 272 | 1.38k | buf.push_back(0x5c); | 273 | 1.38k | buf.push_back('r'); | 274 | 1.38k | break; | 275 | | | 276 | 1.08k | case 0x22: | 277 | | /* \" double quote */ | 278 | 1.08k | buf.push_back(0x5c); | 279 | 1.08k | buf.push_back(0x22); | 280 | 1.08k | break; | 281 | | | 282 | 2.54k | case 0x5c: | 283 | | /* \\ backslash */ | 284 | 2.54k | buf.push_back(0x5c); | 285 | 2.54k | buf.push_back(0x5c); | 286 | 2.54k | break; | 287 | | | 288 | 338k | default: | 289 | 338k | buf.push_back(0x5c); | 290 | 338k | buf.push_back(0x75); // 'u' | 291 | 338k | buf.push_back(toHexDigit((ch & 0xF000) >> 12)); | 292 | 338k | buf.push_back(toHexDigit((ch & 0xF00) >> 8)); | 293 | 338k | buf.push_back(toHexDigit((ch & 0xF0) >> 4)); | 294 | 338k | buf.push_back(toHexDigit(ch & 0xF)); | 295 | 338k | break; | 296 | 349k | } | 297 | 349k | } | 298 | 31.2k | buf.append(start, input.end()); | 299 | | | 300 | | /* add trailing quote */ | 301 | 31.2k | buf.push_back(0x22); | 302 | 31.2k | } |
log4cxx::JSONLayout::appendItem(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) Line | Count | Source | 214 | 40.4k | { | 215 | 40.4k | auto toHexDigit = [](int ch) -> int | 216 | 40.4k | { | 217 | 40.4k | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 40.4k | }; | 219 | | /* add leading quote */ | 220 | 40.4k | buf.push_back(0x22); | 221 | | | 222 | 40.4k | auto start = input.begin(); | 223 | 1.28M | for (auto nextCodePoint = start; input.end() != nextCodePoint; ) | 224 | 1.24M | { | 225 | 1.24M | auto lastCodePoint = nextCodePoint; | 226 | 1.24M | auto ch = Transcoder::decode(input, nextCodePoint); | 227 | 1.24M | if (nextCodePoint == lastCodePoint) // failed to decode input? | 228 | 0 | { | 229 | 0 | nextCodePoint = input.end(); | 230 | 0 | ch = 0xFFFD; // The Unicode replacement character | 231 | 0 | } | 232 | 1.24M | else if ((0xD800 <= ch && ch <= 0xDFFF) || 0x10FFFF < ch) | 233 | 0 | { | 234 | 0 | ch = 0xFFFD; // The Unicode replacement character | 235 | 0 | } | 236 | 1.24M | else if (0x22 == ch || 0x5c == ch) // double quote or backslash? | 237 | 13.1k | ; | 238 | 1.22M | else if (0x20 <= ch) // not a control character? | 239 | 524k | continue; | 240 | | | 241 | 716k | if (start != lastCodePoint) | 242 | 25.9k | buf.append(start, lastCodePoint); | 243 | 716k | start = nextCodePoint; | 244 | 716k | switch (ch) | 245 | 716k | { | 246 | 26.6k | case 0x08: | 247 | | /* \b backspace */ | 248 | 26.6k | buf.push_back(0x5c); | 249 | 26.6k | buf.push_back('b'); | 250 | 26.6k | break; | 251 | | | 252 | 3.83k | case 0x09: | 253 | | /* \t tab */ | 254 | 3.83k | buf.push_back(0x5c); | 255 | 3.83k | buf.push_back('t'); | 256 | 3.83k | break; | 257 | | | 258 | 14.7k | case 0x0a: | 259 | | /* \n newline */ | 260 | 14.7k | buf.push_back(0x5c); | 261 | 14.7k | buf.push_back('n'); | 262 | 14.7k | break; | 263 | | | 264 | 22.8k | case 0x0c: | 265 | | /* \f form feed */ | 266 | 22.8k | buf.push_back(0x5c); | 267 | 22.8k | buf.push_back('f'); | 268 | 22.8k | break; | 269 | | | 270 | 12.9k | case 0x0d: | 271 | | /* \r carriage return */ | 272 | 12.9k | buf.push_back(0x5c); | 273 | 12.9k | buf.push_back('r'); | 274 | 12.9k | break; | 275 | | | 276 | 9.16k | case 0x22: | 277 | | /* \" double quote */ | 278 | 9.16k | buf.push_back(0x5c); | 279 | 9.16k | buf.push_back(0x22); | 280 | 9.16k | break; | 281 | | | 282 | 3.95k | case 0x5c: | 283 | | /* \\ backslash */ | 284 | 3.95k | buf.push_back(0x5c); | 285 | 3.95k | buf.push_back(0x5c); | 286 | 3.95k | break; | 287 | | | 288 | 622k | default: | 289 | 622k | buf.push_back(0x5c); | 290 | 622k | buf.push_back(0x75); // 'u' | 291 | 622k | buf.push_back(toHexDigit((ch & 0xF000) >> 12)); | 292 | 622k | buf.push_back(toHexDigit((ch & 0xF00) >> 8)); | 293 | 622k | buf.push_back(toHexDigit((ch & 0xF0) >> 4)); | 294 | 622k | buf.push_back(toHexDigit(ch & 0xF)); | 295 | 622k | break; | 296 | 716k | } | 297 | 716k | } | 298 | 40.4k | buf.append(start, input.end()); | 299 | | | 300 | | /* add trailing quote */ | 301 | 40.4k | buf.push_back(0x22); | 302 | 40.4k | } |
|
303 | | |
304 | | void JSONLayout::appendSerializedMDC(LogString& buf, |
305 | | const LoggingEventPtr& event) const |
306 | 4.79k | { |
307 | 4.79k | LoggingEvent::KeySet keys = event->getMDCKeySet(); |
308 | | |
309 | 4.79k | if (keys.empty()) |
310 | 0 | { |
311 | 0 | return; |
312 | 0 | } |
313 | | |
314 | 4.79k | buf.append(LOG4CXX_STR(",")); |
315 | 4.79k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
316 | | |
317 | 4.79k | if (m_priv->prettyPrint) |
318 | 2.27k | { |
319 | 2.27k | buf.append(m_priv->ppIndentL1); |
320 | 2.27k | } |
321 | | |
322 | 4.79k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); |
323 | 4.79k | buf.append(LOG4CXX_STR(": {")); |
324 | 4.79k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
325 | | |
326 | 4.79k | for (LoggingEvent::KeySet::iterator it = keys.begin(); |
327 | 11.6k | it != keys.end(); ++it) |
328 | 6.82k | { |
329 | 6.82k | if (m_priv->prettyPrint) |
330 | 3.46k | { |
331 | 3.46k | buf.append(m_priv->ppIndentL2); |
332 | 3.46k | } |
333 | | |
334 | 6.82k | appendQuotedEscapedString(buf, *it); |
335 | 6.82k | buf.append(LOG4CXX_STR(": ")); |
336 | 6.82k | LogString value; |
337 | 6.82k | event->getMDC(*it, value); |
338 | 6.82k | appendQuotedEscapedString(buf, value); |
339 | | |
340 | | /* if this isn't the last k:v pair, we need a comma */ |
341 | 6.82k | if (it + 1 != keys.end()) |
342 | 2.02k | { |
343 | 2.02k | buf.append(LOG4CXX_STR(",")); |
344 | 2.02k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
345 | 2.02k | } |
346 | 4.79k | else |
347 | 4.79k | { |
348 | 4.79k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
349 | 4.79k | } |
350 | 6.82k | } |
351 | | |
352 | 4.79k | if (m_priv->prettyPrint) |
353 | 2.27k | { |
354 | 2.27k | buf.append(m_priv->ppIndentL1); |
355 | 2.27k | } |
356 | | |
357 | 4.79k | buf.append(LOG4CXX_STR("}")); |
358 | 4.79k | } log4cxx::JSONLayout::appendSerializedMDC(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&) const Line | Count | Source | 306 | 2.07k | { | 307 | 2.07k | LoggingEvent::KeySet keys = event->getMDCKeySet(); | 308 | | | 309 | 2.07k | if (keys.empty()) | 310 | 0 | { | 311 | 0 | return; | 312 | 0 | } | 313 | | | 314 | 2.07k | buf.append(LOG4CXX_STR(",")); | 315 | 2.07k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 316 | | | 317 | 2.07k | if (m_priv->prettyPrint) | 318 | 960 | { | 319 | 960 | buf.append(m_priv->ppIndentL1); | 320 | 960 | } | 321 | | | 322 | 2.07k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); | 323 | 2.07k | buf.append(LOG4CXX_STR(": {")); | 324 | 2.07k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 325 | | | 326 | 2.07k | for (LoggingEvent::KeySet::iterator it = keys.begin(); | 327 | 5.09k | it != keys.end(); ++it) | 328 | 3.01k | { | 329 | 3.01k | if (m_priv->prettyPrint) | 330 | 1.48k | { | 331 | 1.48k | buf.append(m_priv->ppIndentL2); | 332 | 1.48k | } | 333 | | | 334 | 3.01k | appendQuotedEscapedString(buf, *it); | 335 | 3.01k | buf.append(LOG4CXX_STR(": ")); | 336 | 3.01k | LogString value; | 337 | 3.01k | event->getMDC(*it, value); | 338 | 3.01k | appendQuotedEscapedString(buf, value); | 339 | | | 340 | | /* if this isn't the last k:v pair, we need a comma */ | 341 | 3.01k | if (it + 1 != keys.end()) | 342 | 940 | { | 343 | 940 | buf.append(LOG4CXX_STR(",")); | 344 | 940 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 345 | 940 | } | 346 | 2.07k | else | 347 | 2.07k | { | 348 | 2.07k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 349 | 2.07k | } | 350 | 3.01k | } | 351 | | | 352 | 2.07k | if (m_priv->prettyPrint) | 353 | 960 | { | 354 | 960 | buf.append(m_priv->ppIndentL1); | 355 | 960 | } | 356 | | | 357 | 2.07k | buf.append(LOG4CXX_STR("}")); | 358 | 2.07k | } |
log4cxx::JSONLayout::appendSerializedMDC(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&, std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&) const Line | Count | Source | 306 | 2.71k | { | 307 | 2.71k | LoggingEvent::KeySet keys = event->getMDCKeySet(); | 308 | | | 309 | 2.71k | if (keys.empty()) | 310 | 0 | { | 311 | 0 | return; | 312 | 0 | } | 313 | | | 314 | 2.71k | buf.append(LOG4CXX_STR(",")); | 315 | 2.71k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 316 | | | 317 | 2.71k | if (m_priv->prettyPrint) | 318 | 1.31k | { | 319 | 1.31k | buf.append(m_priv->ppIndentL1); | 320 | 1.31k | } | 321 | | | 322 | 2.71k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); | 323 | 2.71k | buf.append(LOG4CXX_STR(": {")); | 324 | 2.71k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 325 | | | 326 | 2.71k | for (LoggingEvent::KeySet::iterator it = keys.begin(); | 327 | 6.52k | it != keys.end(); ++it) | 328 | 3.80k | { | 329 | 3.80k | if (m_priv->prettyPrint) | 330 | 1.97k | { | 331 | 1.97k | buf.append(m_priv->ppIndentL2); | 332 | 1.97k | } | 333 | | | 334 | 3.80k | appendQuotedEscapedString(buf, *it); | 335 | 3.80k | buf.append(LOG4CXX_STR(": ")); | 336 | 3.80k | LogString value; | 337 | 3.80k | event->getMDC(*it, value); | 338 | 3.80k | appendQuotedEscapedString(buf, value); | 339 | | | 340 | | /* if this isn't the last k:v pair, we need a comma */ | 341 | 3.80k | if (it + 1 != keys.end()) | 342 | 1.08k | { | 343 | 1.08k | buf.append(LOG4CXX_STR(",")); | 344 | 1.08k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 345 | 1.08k | } | 346 | 2.71k | else | 347 | 2.71k | { | 348 | 2.71k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 349 | 2.71k | } | 350 | 3.80k | } | 351 | | | 352 | 2.71k | if (m_priv->prettyPrint) | 353 | 1.31k | { | 354 | 1.31k | buf.append(m_priv->ppIndentL1); | 355 | 1.31k | } | 356 | | | 357 | 2.71k | buf.append(LOG4CXX_STR("}")); | 358 | 2.71k | } |
|
359 | | |
360 | | void JSONLayout::appendSerializedNDC(LogString& buf, |
361 | | const LoggingEventPtr& event) const |
362 | 4.79k | { |
363 | 4.79k | LogString ndcVal; |
364 | | |
365 | 4.79k | if (!event->getNDC(ndcVal)) |
366 | 0 | { |
367 | 0 | return; |
368 | 0 | } |
369 | | |
370 | 4.79k | buf.append(LOG4CXX_STR(",")); |
371 | 4.79k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
372 | | |
373 | 4.79k | if (m_priv->prettyPrint) |
374 | 2.27k | { |
375 | 2.27k | buf.append(m_priv->ppIndentL1); |
376 | 2.27k | } |
377 | | |
378 | 4.79k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); |
379 | 4.79k | buf.append(LOG4CXX_STR(": [")); |
380 | 4.79k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
381 | | |
382 | 4.79k | if (m_priv->prettyPrint) |
383 | 2.27k | { |
384 | 2.27k | buf.append(m_priv->ppIndentL2); |
385 | 2.27k | } |
386 | | |
387 | 4.79k | appendQuotedEscapedString(buf, ndcVal); |
388 | 4.79k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
389 | | |
390 | 4.79k | if (m_priv->prettyPrint) |
391 | 2.27k | { |
392 | 2.27k | buf.append(m_priv->ppIndentL1); |
393 | 2.27k | } |
394 | | |
395 | 4.79k | buf.append(LOG4CXX_STR("]")); |
396 | 4.79k | } log4cxx::JSONLayout::appendSerializedNDC(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&) const Line | Count | Source | 362 | 2.07k | { | 363 | 2.07k | LogString ndcVal; | 364 | | | 365 | 2.07k | if (!event->getNDC(ndcVal)) | 366 | 0 | { | 367 | 0 | return; | 368 | 0 | } | 369 | | | 370 | 2.07k | buf.append(LOG4CXX_STR(",")); | 371 | 2.07k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 372 | | | 373 | 2.07k | if (m_priv->prettyPrint) | 374 | 960 | { | 375 | 960 | buf.append(m_priv->ppIndentL1); | 376 | 960 | } | 377 | | | 378 | 2.07k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); | 379 | 2.07k | buf.append(LOG4CXX_STR(": [")); | 380 | 2.07k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 381 | | | 382 | 2.07k | if (m_priv->prettyPrint) | 383 | 960 | { | 384 | 960 | buf.append(m_priv->ppIndentL2); | 385 | 960 | } | 386 | | | 387 | 2.07k | appendQuotedEscapedString(buf, ndcVal); | 388 | 2.07k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 389 | | | 390 | 2.07k | if (m_priv->prettyPrint) | 391 | 960 | { | 392 | 960 | buf.append(m_priv->ppIndentL1); | 393 | 960 | } | 394 | | | 395 | 2.07k | buf.append(LOG4CXX_STR("]")); | 396 | 2.07k | } |
log4cxx::JSONLayout::appendSerializedNDC(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&, std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&) const Line | Count | Source | 362 | 2.71k | { | 363 | 2.71k | LogString ndcVal; | 364 | | | 365 | 2.71k | if (!event->getNDC(ndcVal)) | 366 | 0 | { | 367 | 0 | return; | 368 | 0 | } | 369 | | | 370 | 2.71k | buf.append(LOG4CXX_STR(",")); | 371 | 2.71k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 372 | | | 373 | 2.71k | if (m_priv->prettyPrint) | 374 | 1.31k | { | 375 | 1.31k | buf.append(m_priv->ppIndentL1); | 376 | 1.31k | } | 377 | | | 378 | 2.71k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); | 379 | 2.71k | buf.append(LOG4CXX_STR(": [")); | 380 | 2.71k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 381 | | | 382 | 2.71k | if (m_priv->prettyPrint) | 383 | 1.31k | { | 384 | 1.31k | buf.append(m_priv->ppIndentL2); | 385 | 1.31k | } | 386 | | | 387 | 2.71k | appendQuotedEscapedString(buf, ndcVal); | 388 | 2.71k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 389 | | | 390 | 2.71k | if (m_priv->prettyPrint) | 391 | 1.31k | { | 392 | 1.31k | buf.append(m_priv->ppIndentL1); | 393 | 1.31k | } | 394 | | | 395 | 2.71k | buf.append(LOG4CXX_STR("]")); | 396 | 2.71k | } |
|
397 | | |
398 | | void JSONLayout::appendSerializedLocationInfo(LogString& buf, const LoggingEventPtr& event) const |
399 | 2.69k | { |
400 | 2.69k | if (m_priv->prettyPrint) |
401 | 1.61k | { |
402 | 1.61k | buf.append(m_priv->ppIndentL1); |
403 | 1.61k | } |
404 | | |
405 | 2.69k | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); |
406 | 2.69k | buf.append(LOG4CXX_STR(": {")); |
407 | 2.69k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
408 | 2.69k | const LocationInfo& locInfo = event->getLocationInformation(); |
409 | | |
410 | 2.69k | if (m_priv->prettyPrint) |
411 | 1.61k | { |
412 | 1.61k | buf.append(m_priv->ppIndentL2); |
413 | 1.61k | } |
414 | | |
415 | 2.69k | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); |
416 | 2.69k | buf.append(LOG4CXX_STR(": ")); |
417 | 2.69k | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); |
418 | 2.69k | appendQuotedEscapedString(buf, fileName); |
419 | 2.69k | buf.append(LOG4CXX_STR(",")); |
420 | 2.69k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
421 | | |
422 | 2.69k | if (m_priv->prettyPrint) |
423 | 1.61k | { |
424 | 1.61k | buf.append(m_priv->ppIndentL2); |
425 | 1.61k | } |
426 | | |
427 | 2.69k | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); |
428 | 2.69k | buf.append(LOG4CXX_STR(": ")); |
429 | 2.69k | LogString lineNumber; |
430 | 2.69k | StringHelper::toString(locInfo.getLineNumber(), lineNumber); |
431 | 2.69k | appendQuotedEscapedString(buf, lineNumber); |
432 | 2.69k | buf.append(LOG4CXX_STR(",")); |
433 | 2.69k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
434 | | |
435 | 2.69k | if (m_priv->prettyPrint) |
436 | 1.61k | { |
437 | 1.61k | buf.append(m_priv->ppIndentL2); |
438 | 1.61k | } |
439 | | |
440 | 2.69k | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); |
441 | 2.69k | buf.append(LOG4CXX_STR(": ")); |
442 | 2.69k | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); |
443 | 2.69k | appendQuotedEscapedString(buf, className); |
444 | 2.69k | buf.append(LOG4CXX_STR(",")); |
445 | 2.69k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
446 | | |
447 | 2.69k | if (m_priv->prettyPrint) |
448 | 1.61k | { |
449 | 1.61k | buf.append(m_priv->ppIndentL2); |
450 | 1.61k | } |
451 | | |
452 | 2.69k | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); |
453 | 2.69k | buf.append(LOG4CXX_STR(": ")); |
454 | 2.69k | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); |
455 | 2.69k | appendQuotedEscapedString(buf, methodName); |
456 | 2.69k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
457 | | |
458 | 2.69k | if (m_priv->prettyPrint) |
459 | 1.61k | { |
460 | 1.61k | buf.append(m_priv->ppIndentL1); |
461 | 1.61k | } |
462 | | |
463 | 2.69k | buf.append(LOG4CXX_STR("}")); |
464 | 2.69k | } log4cxx::JSONLayout::appendSerializedLocationInfo(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&) const Line | Count | Source | 399 | 1.18k | { | 400 | 1.18k | if (m_priv->prettyPrint) | 401 | 681 | { | 402 | 681 | buf.append(m_priv->ppIndentL1); | 403 | 681 | } | 404 | | | 405 | 1.18k | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); | 406 | 1.18k | buf.append(LOG4CXX_STR(": {")); | 407 | 1.18k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 408 | 1.18k | const LocationInfo& locInfo = event->getLocationInformation(); | 409 | | | 410 | 1.18k | if (m_priv->prettyPrint) | 411 | 681 | { | 412 | 681 | buf.append(m_priv->ppIndentL2); | 413 | 681 | } | 414 | | | 415 | 1.18k | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); | 416 | 1.18k | buf.append(LOG4CXX_STR(": ")); | 417 | 1.18k | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); | 418 | 1.18k | appendQuotedEscapedString(buf, fileName); | 419 | 1.18k | buf.append(LOG4CXX_STR(",")); | 420 | 1.18k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 421 | | | 422 | 1.18k | if (m_priv->prettyPrint) | 423 | 681 | { | 424 | 681 | buf.append(m_priv->ppIndentL2); | 425 | 681 | } | 426 | | | 427 | 1.18k | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); | 428 | 1.18k | buf.append(LOG4CXX_STR(": ")); | 429 | 1.18k | LogString lineNumber; | 430 | 1.18k | StringHelper::toString(locInfo.getLineNumber(), lineNumber); | 431 | 1.18k | appendQuotedEscapedString(buf, lineNumber); | 432 | 1.18k | buf.append(LOG4CXX_STR(",")); | 433 | 1.18k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 434 | | | 435 | 1.18k | if (m_priv->prettyPrint) | 436 | 681 | { | 437 | 681 | buf.append(m_priv->ppIndentL2); | 438 | 681 | } | 439 | | | 440 | 1.18k | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); | 441 | 1.18k | buf.append(LOG4CXX_STR(": ")); | 442 | 1.18k | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); | 443 | 1.18k | appendQuotedEscapedString(buf, className); | 444 | 1.18k | buf.append(LOG4CXX_STR(",")); | 445 | 1.18k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 446 | | | 447 | 1.18k | if (m_priv->prettyPrint) | 448 | 681 | { | 449 | 681 | buf.append(m_priv->ppIndentL2); | 450 | 681 | } | 451 | | | 452 | 1.18k | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); | 453 | 1.18k | buf.append(LOG4CXX_STR(": ")); | 454 | 1.18k | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); | 455 | 1.18k | appendQuotedEscapedString(buf, methodName); | 456 | 1.18k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 457 | | | 458 | 1.18k | if (m_priv->prettyPrint) | 459 | 681 | { | 460 | 681 | buf.append(m_priv->ppIndentL1); | 461 | 681 | } | 462 | | | 463 | 1.18k | buf.append(LOG4CXX_STR("}")); | 464 | 1.18k | } |
log4cxx::JSONLayout::appendSerializedLocationInfo(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&, std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&) const Line | Count | Source | 399 | 1.50k | { | 400 | 1.50k | if (m_priv->prettyPrint) | 401 | 936 | { | 402 | 936 | buf.append(m_priv->ppIndentL1); | 403 | 936 | } | 404 | | | 405 | 1.50k | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); | 406 | 1.50k | buf.append(LOG4CXX_STR(": {")); | 407 | 1.50k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 408 | 1.50k | const LocationInfo& locInfo = event->getLocationInformation(); | 409 | | | 410 | 1.50k | if (m_priv->prettyPrint) | 411 | 936 | { | 412 | 936 | buf.append(m_priv->ppIndentL2); | 413 | 936 | } | 414 | | | 415 | 1.50k | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); | 416 | 1.50k | buf.append(LOG4CXX_STR(": ")); | 417 | 1.50k | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); | 418 | 1.50k | appendQuotedEscapedString(buf, fileName); | 419 | 1.50k | buf.append(LOG4CXX_STR(",")); | 420 | 1.50k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 421 | | | 422 | 1.50k | if (m_priv->prettyPrint) | 423 | 936 | { | 424 | 936 | buf.append(m_priv->ppIndentL2); | 425 | 936 | } | 426 | | | 427 | 1.50k | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); | 428 | 1.50k | buf.append(LOG4CXX_STR(": ")); | 429 | 1.50k | LogString lineNumber; | 430 | 1.50k | StringHelper::toString(locInfo.getLineNumber(), lineNumber); | 431 | 1.50k | appendQuotedEscapedString(buf, lineNumber); | 432 | 1.50k | buf.append(LOG4CXX_STR(",")); | 433 | 1.50k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 434 | | | 435 | 1.50k | if (m_priv->prettyPrint) | 436 | 936 | { | 437 | 936 | buf.append(m_priv->ppIndentL2); | 438 | 936 | } | 439 | | | 440 | 1.50k | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); | 441 | 1.50k | buf.append(LOG4CXX_STR(": ")); | 442 | 1.50k | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); | 443 | 1.50k | appendQuotedEscapedString(buf, className); | 444 | 1.50k | buf.append(LOG4CXX_STR(",")); | 445 | 1.50k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 446 | | | 447 | 1.50k | if (m_priv->prettyPrint) | 448 | 936 | { | 449 | 936 | buf.append(m_priv->ppIndentL2); | 450 | 936 | } | 451 | | | 452 | 1.50k | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); | 453 | 1.50k | buf.append(LOG4CXX_STR(": ")); | 454 | 1.50k | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); | 455 | 1.50k | appendQuotedEscapedString(buf, methodName); | 456 | 1.50k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 457 | | | 458 | 1.50k | if (m_priv->prettyPrint) | 459 | 936 | { | 460 | 936 | buf.append(m_priv->ppIndentL1); | 461 | 936 | } | 462 | | | 463 | 1.50k | buf.append(LOG4CXX_STR("}")); | 464 | 1.50k | } |
|
465 | | |
466 | | #if LOG4CXX_ABI_VERSION <= 15 |
467 | | void JSONLayout::appendSerializedLocationInfo(LogString& buf, |
468 | | const LoggingEventPtr& event, Pool& p) const |
469 | 0 | { |
470 | 0 | appendSerializedLocationInfo(buf, event); |
471 | 0 | } Unexecuted instantiation: log4cxx::JSONLayout::appendSerializedLocationInfo(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&, log4cxx::helpers::Pool&) const Unexecuted instantiation: log4cxx::JSONLayout::appendSerializedLocationInfo(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&, std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&, log4cxx::helpers::Pool&) const |
472 | | #endif |