/src/logging-log4cxx/src/main/cpp/jsonlayout.cpp
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 | | #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 | | |
28 | | #include <string.h> |
29 | | |
30 | | using namespace LOG4CXX_NS; |
31 | | using namespace LOG4CXX_NS::helpers; |
32 | | using namespace LOG4CXX_NS::spi; |
33 | | |
34 | | IMPLEMENT_LOG4CXX_OBJECT(JSONLayout) |
35 | | |
36 | | struct JSONLayout::JSONLayoutPrivate |
37 | | { |
38 | | JSONLayoutPrivate() : |
39 | 3.06k | locationInfo(false), |
40 | 3.06k | prettyPrint(false), |
41 | 3.06k | ppIndentL1(LOG4CXX_STR(" ")), |
42 | 3.06k | ppIndentL2(LOG4CXX_STR(" ")), |
43 | 3.06k | expectedPatternLength(100), |
44 | 3.06k | threadInfo(false) {} |
45 | | |
46 | | // Print no location info by default |
47 | | bool locationInfo; //= false |
48 | | bool prettyPrint; //= false |
49 | | |
50 | | pattern::CachedDateFormat dateFormat |
51 | | { std::make_shared<helpers::SimpleDateFormat>(LOG4CXX_STR("yyyy-MM-dd HH:mm:ss,SSS")) |
52 | | , pattern::CachedDateFormat::getMaximumCacheValidity(LOG4CXX_STR("yyyy-MM-dd HH:mm:ss,SSS")) |
53 | | }; |
54 | | |
55 | | LogString ppIndentL1; |
56 | | LogString ppIndentL2; |
57 | | |
58 | | // Expected length of a formatted event excluding the message text |
59 | | size_t expectedPatternLength; |
60 | | |
61 | | // Thread info is not included by default |
62 | | bool threadInfo; //= false |
63 | | }; |
64 | | |
65 | | JSONLayout::JSONLayout() : |
66 | 3.06k | m_priv(std::make_unique<JSONLayoutPrivate>()) |
67 | 3.06k | { |
68 | 3.06k | } Unexecuted instantiation: log4cxx::JSONLayout::JSONLayout() log4cxx::JSONLayout::JSONLayout() Line | Count | Source | 66 | 3.06k | m_priv(std::make_unique<JSONLayoutPrivate>()) | 67 | 3.06k | { | 68 | 3.06k | } |
|
69 | | |
70 | 3.06k | JSONLayout::~JSONLayout(){} |
71 | | |
72 | | void JSONLayout::setLocationInfo(bool locationInfoFlag) |
73 | 2.04k | { |
74 | 2.04k | m_priv->locationInfo = locationInfoFlag; |
75 | 2.04k | } |
76 | | |
77 | | bool JSONLayout::getLocationInfo() const |
78 | 0 | { |
79 | 0 | return m_priv->locationInfo; |
80 | 0 | } |
81 | | |
82 | | void JSONLayout::setPrettyPrint(bool prettyPrintFlag) |
83 | 1.65k | { |
84 | 1.65k | m_priv->prettyPrint = prettyPrintFlag; |
85 | 1.65k | } |
86 | | |
87 | | bool JSONLayout::getPrettyPrint() const |
88 | 0 | { |
89 | 0 | return m_priv->prettyPrint; |
90 | 0 | } |
91 | | |
92 | | void JSONLayout::setThreadInfo(bool newValue) |
93 | 1.81k | { |
94 | 1.81k | m_priv->threadInfo = newValue; |
95 | 1.81k | } |
96 | | |
97 | | bool JSONLayout::getThreadInfo() const |
98 | 0 | { |
99 | 0 | return m_priv->threadInfo; |
100 | 0 | } |
101 | | |
102 | | LogString JSONLayout::getContentType() const |
103 | 0 | { |
104 | 0 | return LOG4CXX_STR("application/json"); |
105 | 0 | } |
106 | | |
107 | | void JSONLayout::activateOptions(helpers::Pool& /* p */) |
108 | 0 | { |
109 | 0 | m_priv->expectedPatternLength = getFormattedEventCharacterCount() * 2; |
110 | 0 | } |
111 | | |
112 | | void JSONLayout::setOption(const LogString& option, const LogString& value) |
113 | 5.52k | { |
114 | 5.52k | if (StringHelper::equalsIgnoreCase(option, |
115 | 5.52k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) |
116 | 2.04k | { |
117 | 2.04k | setLocationInfo(OptionConverter::toBoolean(value, false)); |
118 | 2.04k | } |
119 | 3.47k | else if (StringHelper::equalsIgnoreCase(option, |
120 | 3.47k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) |
121 | 1.81k | { |
122 | 1.81k | setThreadInfo(OptionConverter::toBoolean(value, false)); |
123 | 1.81k | } |
124 | 1.65k | else if (StringHelper::equalsIgnoreCase(option, |
125 | 1.65k | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) |
126 | 1.65k | { |
127 | 1.65k | setPrettyPrint(OptionConverter::toBoolean(value, false)); |
128 | 1.65k | } |
129 | 5.52k | } 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 | 113 | 2.41k | { | 114 | 2.41k | if (StringHelper::equalsIgnoreCase(option, | 115 | 2.41k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) | 116 | 885 | { | 117 | 885 | setLocationInfo(OptionConverter::toBoolean(value, false)); | 118 | 885 | } | 119 | 1.52k | else if (StringHelper::equalsIgnoreCase(option, | 120 | 1.52k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) | 121 | 788 | { | 122 | 788 | setThreadInfo(OptionConverter::toBoolean(value, false)); | 123 | 788 | } | 124 | 740 | else if (StringHelper::equalsIgnoreCase(option, | 125 | 740 | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) | 126 | 740 | { | 127 | 740 | setPrettyPrint(OptionConverter::toBoolean(value, false)); | 128 | 740 | } | 129 | 2.41k | } |
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 | 113 | 3.10k | { | 114 | 3.10k | if (StringHelper::equalsIgnoreCase(option, | 115 | 3.10k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) | 116 | 1.16k | { | 117 | 1.16k | setLocationInfo(OptionConverter::toBoolean(value, false)); | 118 | 1.16k | } | 119 | 1.94k | else if (StringHelper::equalsIgnoreCase(option, | 120 | 1.94k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) | 121 | 1.03k | { | 122 | 1.03k | setThreadInfo(OptionConverter::toBoolean(value, false)); | 123 | 1.03k | } | 124 | 917 | else if (StringHelper::equalsIgnoreCase(option, | 125 | 917 | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) | 126 | 917 | { | 127 | 917 | setPrettyPrint(OptionConverter::toBoolean(value, false)); | 128 | 917 | } | 129 | 3.10k | } |
|
130 | | |
131 | | void JSONLayout::format(LogString& output, |
132 | | const spi::LoggingEventPtr& event, |
133 | | Pool& p) const |
134 | 3.06k | { |
135 | 3.06k | output.reserve(m_priv->expectedPatternLength + event->getMessage().size()); |
136 | 3.06k | output.append(LOG4CXX_STR("{")); |
137 | 3.06k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
138 | | |
139 | 3.06k | if (m_priv->prettyPrint) |
140 | 1.65k | { |
141 | 1.65k | output.append(m_priv->ppIndentL1); |
142 | 1.65k | } |
143 | | |
144 | 3.06k | output.append(LOG4CXX_STR("\"timestamp\": \"")); |
145 | 3.06k | m_priv->dateFormat.format(output, event->getTimeStamp(), p); |
146 | 3.06k | output.append(LOG4CXX_STR("\",")); |
147 | 3.06k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
148 | | |
149 | 3.06k | if (m_priv->threadInfo) |
150 | 1.81k | { |
151 | 1.81k | if (m_priv->prettyPrint) |
152 | 1.23k | { |
153 | 1.23k | output.append(m_priv->ppIndentL1); |
154 | 1.23k | } |
155 | 1.81k | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); |
156 | 1.81k | output.append(LOG4CXX_STR(": ")); |
157 | 1.81k | appendQuotedEscapedString(output, event->getThreadName()); |
158 | 1.81k | output.append(LOG4CXX_STR(",")); |
159 | 1.81k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
160 | 1.81k | } |
161 | | |
162 | 3.06k | if (m_priv->prettyPrint) |
163 | 1.65k | { |
164 | 1.65k | output.append(m_priv->ppIndentL1); |
165 | 1.65k | } |
166 | | |
167 | 3.06k | output.append(LOG4CXX_STR("\"level\": ")); |
168 | 3.06k | LogString level; |
169 | 3.06k | event->getLevel()->toString(level); |
170 | 3.06k | appendQuotedEscapedString(output, level); |
171 | 3.06k | output.append(LOG4CXX_STR(",")); |
172 | 3.06k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
173 | | |
174 | 3.06k | if (m_priv->prettyPrint) |
175 | 1.65k | { |
176 | 1.65k | output.append(m_priv->ppIndentL1); |
177 | 1.65k | } |
178 | | |
179 | 3.06k | output.append(LOG4CXX_STR("\"logger\": ")); |
180 | 3.06k | appendQuotedEscapedString(output, event->getLoggerName()); |
181 | 3.06k | output.append(LOG4CXX_STR(",")); |
182 | 3.06k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
183 | | |
184 | 3.06k | if (m_priv->prettyPrint) |
185 | 1.65k | { |
186 | 1.65k | output.append(m_priv->ppIndentL1); |
187 | 1.65k | } |
188 | | |
189 | 3.06k | output.append(LOG4CXX_STR("\"message\": ")); |
190 | 3.06k | appendQuotedEscapedString(output, event->getMessage()); |
191 | | |
192 | 3.06k | appendSerializedMDC(output, event); |
193 | 3.06k | appendSerializedNDC(output, event); |
194 | | |
195 | 3.06k | if (m_priv->locationInfo) |
196 | 2.04k | { |
197 | 2.04k | output.append(LOG4CXX_STR(",")); |
198 | 2.04k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
199 | 2.04k | appendSerializedLocationInfo(output, event, p); |
200 | 2.04k | } |
201 | | |
202 | 3.06k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
203 | 3.06k | output.append(LOG4CXX_STR("}")); |
204 | 3.06k | output.append(LOG4CXX_EOL); |
205 | 3.06k | } 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 | 134 | 1.29k | { | 135 | 1.29k | output.reserve(m_priv->expectedPatternLength + event->getMessage().size()); | 136 | 1.29k | output.append(LOG4CXX_STR("{")); | 137 | 1.29k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 138 | | | 139 | 1.29k | if (m_priv->prettyPrint) | 140 | 740 | { | 141 | 740 | output.append(m_priv->ppIndentL1); | 142 | 740 | } | 143 | | | 144 | 1.29k | output.append(LOG4CXX_STR("\"timestamp\": \"")); | 145 | 1.29k | m_priv->dateFormat.format(output, event->getTimeStamp(), p); | 146 | 1.29k | output.append(LOG4CXX_STR("\",")); | 147 | 1.29k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 148 | | | 149 | 1.29k | if (m_priv->threadInfo) | 150 | 788 | { | 151 | 788 | if (m_priv->prettyPrint) | 152 | 565 | { | 153 | 565 | output.append(m_priv->ppIndentL1); | 154 | 565 | } | 155 | 788 | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); | 156 | 788 | output.append(LOG4CXX_STR(": ")); | 157 | 788 | appendQuotedEscapedString(output, event->getThreadName()); | 158 | 788 | output.append(LOG4CXX_STR(",")); | 159 | 788 | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 160 | 788 | } | 161 | | | 162 | 1.29k | if (m_priv->prettyPrint) | 163 | 740 | { | 164 | 740 | output.append(m_priv->ppIndentL1); | 165 | 740 | } | 166 | | | 167 | 1.29k | output.append(LOG4CXX_STR("\"level\": ")); | 168 | 1.29k | LogString level; | 169 | 1.29k | event->getLevel()->toString(level); | 170 | 1.29k | appendQuotedEscapedString(output, level); | 171 | 1.29k | output.append(LOG4CXX_STR(",")); | 172 | 1.29k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 173 | | | 174 | 1.29k | if (m_priv->prettyPrint) | 175 | 740 | { | 176 | 740 | output.append(m_priv->ppIndentL1); | 177 | 740 | } | 178 | | | 179 | 1.29k | output.append(LOG4CXX_STR("\"logger\": ")); | 180 | 1.29k | appendQuotedEscapedString(output, event->getLoggerName()); | 181 | 1.29k | output.append(LOG4CXX_STR(",")); | 182 | 1.29k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 183 | | | 184 | 1.29k | if (m_priv->prettyPrint) | 185 | 740 | { | 186 | 740 | output.append(m_priv->ppIndentL1); | 187 | 740 | } | 188 | | | 189 | 1.29k | output.append(LOG4CXX_STR("\"message\": ")); | 190 | 1.29k | appendQuotedEscapedString(output, event->getMessage()); | 191 | | | 192 | 1.29k | appendSerializedMDC(output, event); | 193 | 1.29k | appendSerializedNDC(output, event); | 194 | | | 195 | 1.29k | if (m_priv->locationInfo) | 196 | 885 | { | 197 | 885 | output.append(LOG4CXX_STR(",")); | 198 | 885 | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 199 | 885 | appendSerializedLocationInfo(output, event, p); | 200 | 885 | } | 201 | | | 202 | 1.29k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 203 | 1.29k | output.append(LOG4CXX_STR("}")); | 204 | 1.29k | output.append(LOG4CXX_EOL); | 205 | 1.29k | } |
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 | 134 | 1.77k | { | 135 | 1.77k | output.reserve(m_priv->expectedPatternLength + event->getMessage().size()); | 136 | 1.77k | output.append(LOG4CXX_STR("{")); | 137 | 1.77k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 138 | | | 139 | 1.77k | if (m_priv->prettyPrint) | 140 | 917 | { | 141 | 917 | output.append(m_priv->ppIndentL1); | 142 | 917 | } | 143 | | | 144 | 1.77k | output.append(LOG4CXX_STR("\"timestamp\": \"")); | 145 | 1.77k | m_priv->dateFormat.format(output, event->getTimeStamp(), p); | 146 | 1.77k | output.append(LOG4CXX_STR("\",")); | 147 | 1.77k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 148 | | | 149 | 1.77k | if (m_priv->threadInfo) | 150 | 1.03k | { | 151 | 1.03k | if (m_priv->prettyPrint) | 152 | 672 | { | 153 | 672 | output.append(m_priv->ppIndentL1); | 154 | 672 | } | 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 | 1.77k | if (m_priv->prettyPrint) | 163 | 917 | { | 164 | 917 | output.append(m_priv->ppIndentL1); | 165 | 917 | } | 166 | | | 167 | 1.77k | output.append(LOG4CXX_STR("\"level\": ")); | 168 | 1.77k | LogString level; | 169 | 1.77k | event->getLevel()->toString(level); | 170 | 1.77k | appendQuotedEscapedString(output, level); | 171 | 1.77k | output.append(LOG4CXX_STR(",")); | 172 | 1.77k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 173 | | | 174 | 1.77k | if (m_priv->prettyPrint) | 175 | 917 | { | 176 | 917 | output.append(m_priv->ppIndentL1); | 177 | 917 | } | 178 | | | 179 | 1.77k | output.append(LOG4CXX_STR("\"logger\": ")); | 180 | 1.77k | appendQuotedEscapedString(output, event->getLoggerName()); | 181 | 1.77k | output.append(LOG4CXX_STR(",")); | 182 | 1.77k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 183 | | | 184 | 1.77k | if (m_priv->prettyPrint) | 185 | 917 | { | 186 | 917 | output.append(m_priv->ppIndentL1); | 187 | 917 | } | 188 | | | 189 | 1.77k | output.append(LOG4CXX_STR("\"message\": ")); | 190 | 1.77k | appendQuotedEscapedString(output, event->getMessage()); | 191 | | | 192 | 1.77k | appendSerializedMDC(output, event); | 193 | 1.77k | appendSerializedNDC(output, event); | 194 | | | 195 | 1.77k | if (m_priv->locationInfo) | 196 | 1.16k | { | 197 | 1.16k | output.append(LOG4CXX_STR(",")); | 198 | 1.16k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 199 | 1.16k | appendSerializedLocationInfo(output, event, p); | 200 | 1.16k | } | 201 | | | 202 | 1.77k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 203 | 1.77k | output.append(LOG4CXX_STR("}")); | 204 | 1.77k | output.append(LOG4CXX_EOL); | 205 | 1.77k | } |
|
206 | | |
207 | | void JSONLayout::appendQuotedEscapedString(LogString& buf, |
208 | | const LogString& input) const |
209 | 49.6k | { |
210 | 49.6k | appendItem(input, buf); |
211 | 49.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 | 21.1k | { | 210 | 21.1k | appendItem(input, buf); | 211 | 21.1k | } |
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 | 28.5k | { | 210 | 28.5k | appendItem(input, buf); | 211 | 28.5k | } |
|
212 | | |
213 | | void JSONLayout::appendItem(const LogString& input, LogString& buf) |
214 | 49.6k | { |
215 | 49.6k | auto toHexDigit = [](int ch) -> int |
216 | 3.59M | { |
217 | 3.59M | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; |
218 | 3.59M | }; 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.44M | { | 217 | 1.44M | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 1.44M | }; |
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.15M | { | 217 | 2.15M | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 2.15M | }; |
|
219 | | /* add leading quote */ |
220 | 49.6k | buf.push_back(0x22); |
221 | | |
222 | 49.6k | size_t start = 0; |
223 | 49.6k | size_t index = 0; |
224 | | |
225 | 49.6k | for (int ch : input) |
226 | 1.56M | { |
227 | 1.56M | if (0x22 == ch || 0x5c == ch) |
228 | 10.0k | ; |
229 | 1.55M | else if (0x20 <= ch) |
230 | 564k | { |
231 | 564k | ++index; |
232 | 564k | continue; |
233 | 564k | } |
234 | 997k | if (start < index) |
235 | 33.1k | { |
236 | 33.1k | buf.append(input, start, index - start); |
237 | 33.1k | } |
238 | | |
239 | 997k | switch (ch) |
240 | 997k | { |
241 | 4.84k | case 0x08: |
242 | | /* \b backspace */ |
243 | 4.84k | buf.push_back(0x5c); |
244 | 4.84k | buf.push_back('b'); |
245 | 4.84k | break; |
246 | | |
247 | 6.29k | case 0x09: |
248 | | /* \t tab */ |
249 | 6.29k | buf.push_back(0x5c); |
250 | 6.29k | buf.push_back('t'); |
251 | 6.29k | break; |
252 | | |
253 | 48.4k | case 0x0a: |
254 | | /* \n newline */ |
255 | 48.4k | buf.push_back(0x5c); |
256 | 48.4k | buf.push_back('n'); |
257 | 48.4k | break; |
258 | | |
259 | 18.4k | case 0x0c: |
260 | | /* \f form feed */ |
261 | 18.4k | buf.push_back(0x5c); |
262 | 18.4k | buf.push_back('f'); |
263 | 18.4k | break; |
264 | | |
265 | 10.5k | case 0x0d: |
266 | | /* \r carriage return */ |
267 | 10.5k | buf.push_back(0x5c); |
268 | 10.5k | buf.push_back('r'); |
269 | 10.5k | break; |
270 | | |
271 | 6.40k | case 0x22: |
272 | | /* \" double quote */ |
273 | 6.40k | buf.push_back(0x5c); |
274 | 6.40k | buf.push_back(0x22); |
275 | 6.40k | break; |
276 | | |
277 | 3.68k | case 0x5c: |
278 | | /* \\ backslash */ |
279 | 3.68k | buf.push_back(0x5c); |
280 | 3.68k | buf.push_back(0x5c); |
281 | 3.68k | break; |
282 | | |
283 | 898k | default: |
284 | 898k | buf.push_back(0x5c); |
285 | 898k | buf.push_back(0x75); // 'u' |
286 | 898k | buf.push_back(toHexDigit((ch & 0xF000) >> 12)); |
287 | 898k | buf.push_back(toHexDigit((ch & 0xF00) >> 8)); |
288 | 898k | buf.push_back(toHexDigit((ch & 0xF0) >> 4)); |
289 | 898k | buf.push_back(toHexDigit(ch & 0xF)); |
290 | 898k | break; |
291 | 997k | } |
292 | 997k | start = ++index; |
293 | 997k | } |
294 | | |
295 | 49.6k | if (start < input.size()) |
296 | 30.4k | { |
297 | 30.4k | buf.append(input, start, input.size() - start); |
298 | 30.4k | } |
299 | | |
300 | | /* add trailing quote */ |
301 | 49.6k | buf.push_back(0x22); |
302 | 49.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 | 21.1k | { | 215 | 21.1k | auto toHexDigit = [](int ch) -> int | 216 | 21.1k | { | 217 | 21.1k | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 21.1k | }; | 219 | | /* add leading quote */ | 220 | 21.1k | buf.push_back(0x22); | 221 | | | 222 | 21.1k | size_t start = 0; | 223 | 21.1k | size_t index = 0; | 224 | | | 225 | 21.1k | for (int ch : input) | 226 | 638k | { | 227 | 638k | if (0x22 == ch || 0x5c == ch) | 228 | 4.43k | ; | 229 | 634k | else if (0x20 <= ch) | 230 | 223k | { | 231 | 223k | ++index; | 232 | 223k | continue; | 233 | 223k | } | 234 | 415k | if (start < index) | 235 | 13.8k | { | 236 | 13.8k | buf.append(input, start, index - start); | 237 | 13.8k | } | 238 | | | 239 | 415k | switch (ch) | 240 | 415k | { | 241 | 1.55k | case 0x08: | 242 | | /* \b backspace */ | 243 | 1.55k | buf.push_back(0x5c); | 244 | 1.55k | buf.push_back('b'); | 245 | 1.55k | break; | 246 | | | 247 | 1.98k | case 0x09: | 248 | | /* \t tab */ | 249 | 1.98k | buf.push_back(0x5c); | 250 | 1.98k | buf.push_back('t'); | 251 | 1.98k | break; | 252 | | | 253 | 44.9k | case 0x0a: | 254 | | /* \n newline */ | 255 | 44.9k | buf.push_back(0x5c); | 256 | 44.9k | buf.push_back('n'); | 257 | 44.9k | break; | 258 | | | 259 | 594 | case 0x0c: | 260 | | /* \f form feed */ | 261 | 594 | buf.push_back(0x5c); | 262 | 594 | buf.push_back('f'); | 263 | 594 | break; | 264 | | | 265 | 1.38k | case 0x0d: | 266 | | /* \r carriage return */ | 267 | 1.38k | buf.push_back(0x5c); | 268 | 1.38k | buf.push_back('r'); | 269 | 1.38k | break; | 270 | | | 271 | 1.53k | case 0x22: | 272 | | /* \" double quote */ | 273 | 1.53k | buf.push_back(0x5c); | 274 | 1.53k | buf.push_back(0x22); | 275 | 1.53k | break; | 276 | | | 277 | 2.90k | case 0x5c: | 278 | | /* \\ backslash */ | 279 | 2.90k | buf.push_back(0x5c); | 280 | 2.90k | buf.push_back(0x5c); | 281 | 2.90k | break; | 282 | | | 283 | 360k | default: | 284 | 360k | buf.push_back(0x5c); | 285 | 360k | buf.push_back(0x75); // 'u' | 286 | 360k | buf.push_back(toHexDigit((ch & 0xF000) >> 12)); | 287 | 360k | buf.push_back(toHexDigit((ch & 0xF00) >> 8)); | 288 | 360k | buf.push_back(toHexDigit((ch & 0xF0) >> 4)); | 289 | 360k | buf.push_back(toHexDigit(ch & 0xF)); | 290 | 360k | break; | 291 | 415k | } | 292 | 415k | start = ++index; | 293 | 415k | } | 294 | | | 295 | 21.1k | if (start < input.size()) | 296 | 12.9k | { | 297 | 12.9k | buf.append(input, start, input.size() - start); | 298 | 12.9k | } | 299 | | | 300 | | /* add trailing quote */ | 301 | 21.1k | buf.push_back(0x22); | 302 | 21.1k | } |
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 | 28.5k | { | 215 | 28.5k | auto toHexDigit = [](int ch) -> int | 216 | 28.5k | { | 217 | 28.5k | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 28.5k | }; | 219 | | /* add leading quote */ | 220 | 28.5k | buf.push_back(0x22); | 221 | | | 222 | 28.5k | size_t start = 0; | 223 | 28.5k | size_t index = 0; | 224 | | | 225 | 28.5k | for (int ch : input) | 226 | 923k | { | 227 | 923k | if (0x22 == ch || 0x5c == ch) | 228 | 5.64k | ; | 229 | 917k | else if (0x20 <= ch) | 230 | 341k | { | 231 | 341k | ++index; | 232 | 341k | continue; | 233 | 341k | } | 234 | 582k | if (start < index) | 235 | 19.3k | { | 236 | 19.3k | buf.append(input, start, index - start); | 237 | 19.3k | } | 238 | | | 239 | 582k | switch (ch) | 240 | 582k | { | 241 | 3.28k | case 0x08: | 242 | | /* \b backspace */ | 243 | 3.28k | buf.push_back(0x5c); | 244 | 3.28k | buf.push_back('b'); | 245 | 3.28k | break; | 246 | | | 247 | 4.30k | case 0x09: | 248 | | /* \t tab */ | 249 | 4.30k | buf.push_back(0x5c); | 250 | 4.30k | buf.push_back('t'); | 251 | 4.30k | break; | 252 | | | 253 | 3.45k | case 0x0a: | 254 | | /* \n newline */ | 255 | 3.45k | buf.push_back(0x5c); | 256 | 3.45k | buf.push_back('n'); | 257 | 3.45k | break; | 258 | | | 259 | 17.8k | case 0x0c: | 260 | | /* \f form feed */ | 261 | 17.8k | buf.push_back(0x5c); | 262 | 17.8k | buf.push_back('f'); | 263 | 17.8k | break; | 264 | | | 265 | 9.12k | case 0x0d: | 266 | | /* \r carriage return */ | 267 | 9.12k | buf.push_back(0x5c); | 268 | 9.12k | buf.push_back('r'); | 269 | 9.12k | break; | 270 | | | 271 | 4.86k | case 0x22: | 272 | | /* \" double quote */ | 273 | 4.86k | buf.push_back(0x5c); | 274 | 4.86k | buf.push_back(0x22); | 275 | 4.86k | break; | 276 | | | 277 | 779 | case 0x5c: | 278 | | /* \\ backslash */ | 279 | 779 | buf.push_back(0x5c); | 280 | 779 | buf.push_back(0x5c); | 281 | 779 | break; | 282 | | | 283 | 538k | default: | 284 | 538k | buf.push_back(0x5c); | 285 | 538k | buf.push_back(0x75); // 'u' | 286 | 538k | buf.push_back(toHexDigit((ch & 0xF000) >> 12)); | 287 | 538k | buf.push_back(toHexDigit((ch & 0xF00) >> 8)); | 288 | 538k | buf.push_back(toHexDigit((ch & 0xF0) >> 4)); | 289 | 538k | buf.push_back(toHexDigit(ch & 0xF)); | 290 | 538k | break; | 291 | 582k | } | 292 | 582k | start = ++index; | 293 | 582k | } | 294 | | | 295 | 28.5k | if (start < input.size()) | 296 | 17.5k | { | 297 | 17.5k | buf.append(input, start, input.size() - start); | 298 | 17.5k | } | 299 | | | 300 | | /* add trailing quote */ | 301 | 28.5k | buf.push_back(0x22); | 302 | 28.5k | } |
|
303 | | |
304 | | void JSONLayout::appendSerializedMDC(LogString& buf, |
305 | | const LoggingEventPtr& event) const |
306 | 3.06k | { |
307 | 3.06k | LoggingEvent::KeySet keys = event->getMDCKeySet(); |
308 | | |
309 | 3.06k | if (keys.empty()) |
310 | 0 | { |
311 | 0 | return; |
312 | 0 | } |
313 | | |
314 | 3.06k | buf.append(LOG4CXX_STR(",")); |
315 | 3.06k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
316 | | |
317 | 3.06k | if (m_priv->prettyPrint) |
318 | 1.65k | { |
319 | 1.65k | buf.append(m_priv->ppIndentL1); |
320 | 1.65k | } |
321 | | |
322 | 3.06k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); |
323 | 3.06k | buf.append(LOG4CXX_STR(": {")); |
324 | 3.06k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
325 | | |
326 | 3.06k | for (LoggingEvent::KeySet::iterator it = keys.begin(); |
327 | 7.66k | it != keys.end(); ++it) |
328 | 4.60k | { |
329 | 4.60k | if (m_priv->prettyPrint) |
330 | 2.61k | { |
331 | 2.61k | buf.append(m_priv->ppIndentL2); |
332 | 2.61k | } |
333 | | |
334 | 4.60k | appendQuotedEscapedString(buf, *it); |
335 | 4.60k | buf.append(LOG4CXX_STR(": ")); |
336 | 4.60k | LogString value; |
337 | 4.60k | event->getMDC(*it, value); |
338 | 4.60k | appendQuotedEscapedString(buf, value); |
339 | | |
340 | | /* if this isn't the last k:v pair, we need a comma */ |
341 | 4.60k | if (it + 1 != keys.end()) |
342 | 1.53k | { |
343 | 1.53k | buf.append(LOG4CXX_STR(",")); |
344 | 1.53k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
345 | 1.53k | } |
346 | 3.06k | else |
347 | 3.06k | { |
348 | 3.06k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
349 | 3.06k | } |
350 | 4.60k | } |
351 | | |
352 | 3.06k | if (m_priv->prettyPrint) |
353 | 1.65k | { |
354 | 1.65k | buf.append(m_priv->ppIndentL1); |
355 | 1.65k | } |
356 | | |
357 | 3.06k | buf.append(LOG4CXX_STR("}")); |
358 | 3.06k | } 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 | 1.29k | { | 307 | 1.29k | LoggingEvent::KeySet keys = event->getMDCKeySet(); | 308 | | | 309 | 1.29k | if (keys.empty()) | 310 | 0 | { | 311 | 0 | return; | 312 | 0 | } | 313 | | | 314 | 1.29k | buf.append(LOG4CXX_STR(",")); | 315 | 1.29k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 316 | | | 317 | 1.29k | if (m_priv->prettyPrint) | 318 | 740 | { | 319 | 740 | buf.append(m_priv->ppIndentL1); | 320 | 740 | } | 321 | | | 322 | 1.29k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); | 323 | 1.29k | buf.append(LOG4CXX_STR(": {")); | 324 | 1.29k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 325 | | | 326 | 1.29k | for (LoggingEvent::KeySet::iterator it = keys.begin(); | 327 | 3.20k | it != keys.end(); ++it) | 328 | 1.91k | { | 329 | 1.91k | if (m_priv->prettyPrint) | 330 | 1.18k | { | 331 | 1.18k | buf.append(m_priv->ppIndentL2); | 332 | 1.18k | } | 333 | | | 334 | 1.91k | appendQuotedEscapedString(buf, *it); | 335 | 1.91k | buf.append(LOG4CXX_STR(": ")); | 336 | 1.91k | LogString value; | 337 | 1.91k | event->getMDC(*it, value); | 338 | 1.91k | appendQuotedEscapedString(buf, value); | 339 | | | 340 | | /* if this isn't the last k:v pair, we need a comma */ | 341 | 1.91k | if (it + 1 != keys.end()) | 342 | 626 | { | 343 | 626 | buf.append(LOG4CXX_STR(",")); | 344 | 626 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 345 | 626 | } | 346 | 1.29k | else | 347 | 1.29k | { | 348 | 1.29k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 349 | 1.29k | } | 350 | 1.91k | } | 351 | | | 352 | 1.29k | if (m_priv->prettyPrint) | 353 | 740 | { | 354 | 740 | buf.append(m_priv->ppIndentL1); | 355 | 740 | } | 356 | | | 357 | 1.29k | buf.append(LOG4CXX_STR("}")); | 358 | 1.29k | } |
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 | 1.77k | { | 307 | 1.77k | LoggingEvent::KeySet keys = event->getMDCKeySet(); | 308 | | | 309 | 1.77k | if (keys.empty()) | 310 | 0 | { | 311 | 0 | return; | 312 | 0 | } | 313 | | | 314 | 1.77k | buf.append(LOG4CXX_STR(",")); | 315 | 1.77k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 316 | | | 317 | 1.77k | if (m_priv->prettyPrint) | 318 | 917 | { | 319 | 917 | buf.append(m_priv->ppIndentL1); | 320 | 917 | } | 321 | | | 322 | 1.77k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); | 323 | 1.77k | buf.append(LOG4CXX_STR(": {")); | 324 | 1.77k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 325 | | | 326 | 1.77k | for (LoggingEvent::KeySet::iterator it = keys.begin(); | 327 | 4.46k | it != keys.end(); ++it) | 328 | 2.68k | { | 329 | 2.68k | if (m_priv->prettyPrint) | 330 | 1.42k | { | 331 | 1.42k | buf.append(m_priv->ppIndentL2); | 332 | 1.42k | } | 333 | | | 334 | 2.68k | appendQuotedEscapedString(buf, *it); | 335 | 2.68k | buf.append(LOG4CXX_STR(": ")); | 336 | 2.68k | LogString value; | 337 | 2.68k | event->getMDC(*it, value); | 338 | 2.68k | appendQuotedEscapedString(buf, value); | 339 | | | 340 | | /* if this isn't the last k:v pair, we need a comma */ | 341 | 2.68k | if (it + 1 != keys.end()) | 342 | 908 | { | 343 | 908 | buf.append(LOG4CXX_STR(",")); | 344 | 908 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 345 | 908 | } | 346 | 1.77k | else | 347 | 1.77k | { | 348 | 1.77k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 349 | 1.77k | } | 350 | 2.68k | } | 351 | | | 352 | 1.77k | if (m_priv->prettyPrint) | 353 | 917 | { | 354 | 917 | buf.append(m_priv->ppIndentL1); | 355 | 917 | } | 356 | | | 357 | 1.77k | buf.append(LOG4CXX_STR("}")); | 358 | 1.77k | } |
|
359 | | |
360 | | void JSONLayout::appendSerializedNDC(LogString& buf, |
361 | | const LoggingEventPtr& event) const |
362 | 3.06k | { |
363 | 3.06k | LogString ndcVal; |
364 | | |
365 | 3.06k | if (!event->getNDC(ndcVal)) |
366 | 0 | { |
367 | 0 | return; |
368 | 0 | } |
369 | | |
370 | 3.06k | buf.append(LOG4CXX_STR(",")); |
371 | 3.06k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
372 | | |
373 | 3.06k | if (m_priv->prettyPrint) |
374 | 1.65k | { |
375 | 1.65k | buf.append(m_priv->ppIndentL1); |
376 | 1.65k | } |
377 | | |
378 | 3.06k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); |
379 | 3.06k | buf.append(LOG4CXX_STR(": [")); |
380 | 3.06k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
381 | | |
382 | 3.06k | if (m_priv->prettyPrint) |
383 | 1.65k | { |
384 | 1.65k | buf.append(m_priv->ppIndentL2); |
385 | 1.65k | } |
386 | | |
387 | 3.06k | appendQuotedEscapedString(buf, ndcVal); |
388 | 3.06k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
389 | | |
390 | 3.06k | if (m_priv->prettyPrint) |
391 | 1.65k | { |
392 | 1.65k | buf.append(m_priv->ppIndentL1); |
393 | 1.65k | } |
394 | | |
395 | 3.06k | buf.append(LOG4CXX_STR("]")); |
396 | 3.06k | } 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 | 1.29k | { | 363 | 1.29k | LogString ndcVal; | 364 | | | 365 | 1.29k | if (!event->getNDC(ndcVal)) | 366 | 0 | { | 367 | 0 | return; | 368 | 0 | } | 369 | | | 370 | 1.29k | buf.append(LOG4CXX_STR(",")); | 371 | 1.29k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 372 | | | 373 | 1.29k | if (m_priv->prettyPrint) | 374 | 740 | { | 375 | 740 | buf.append(m_priv->ppIndentL1); | 376 | 740 | } | 377 | | | 378 | 1.29k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); | 379 | 1.29k | buf.append(LOG4CXX_STR(": [")); | 380 | 1.29k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 381 | | | 382 | 1.29k | if (m_priv->prettyPrint) | 383 | 740 | { | 384 | 740 | buf.append(m_priv->ppIndentL2); | 385 | 740 | } | 386 | | | 387 | 1.29k | appendQuotedEscapedString(buf, ndcVal); | 388 | 1.29k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 389 | | | 390 | 1.29k | if (m_priv->prettyPrint) | 391 | 740 | { | 392 | 740 | buf.append(m_priv->ppIndentL1); | 393 | 740 | } | 394 | | | 395 | 1.29k | buf.append(LOG4CXX_STR("]")); | 396 | 1.29k | } |
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 | 1.77k | { | 363 | 1.77k | LogString ndcVal; | 364 | | | 365 | 1.77k | if (!event->getNDC(ndcVal)) | 366 | 0 | { | 367 | 0 | return; | 368 | 0 | } | 369 | | | 370 | 1.77k | buf.append(LOG4CXX_STR(",")); | 371 | 1.77k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 372 | | | 373 | 1.77k | if (m_priv->prettyPrint) | 374 | 917 | { | 375 | 917 | buf.append(m_priv->ppIndentL1); | 376 | 917 | } | 377 | | | 378 | 1.77k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); | 379 | 1.77k | buf.append(LOG4CXX_STR(": [")); | 380 | 1.77k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 381 | | | 382 | 1.77k | if (m_priv->prettyPrint) | 383 | 917 | { | 384 | 917 | buf.append(m_priv->ppIndentL2); | 385 | 917 | } | 386 | | | 387 | 1.77k | appendQuotedEscapedString(buf, ndcVal); | 388 | 1.77k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 389 | | | 390 | 1.77k | if (m_priv->prettyPrint) | 391 | 917 | { | 392 | 917 | buf.append(m_priv->ppIndentL1); | 393 | 917 | } | 394 | | | 395 | 1.77k | buf.append(LOG4CXX_STR("]")); | 396 | 1.77k | } |
|
397 | | |
398 | | void JSONLayout::appendSerializedLocationInfo(LogString& buf, |
399 | | const LoggingEventPtr& event, Pool& p) const |
400 | 2.04k | { |
401 | 2.04k | if (m_priv->prettyPrint) |
402 | 1.30k | { |
403 | 1.30k | buf.append(m_priv->ppIndentL1); |
404 | 1.30k | } |
405 | | |
406 | 2.04k | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); |
407 | 2.04k | buf.append(LOG4CXX_STR(": {")); |
408 | 2.04k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
409 | 2.04k | const LocationInfo& locInfo = event->getLocationInformation(); |
410 | | |
411 | 2.04k | if (m_priv->prettyPrint) |
412 | 1.30k | { |
413 | 1.30k | buf.append(m_priv->ppIndentL2); |
414 | 1.30k | } |
415 | | |
416 | 2.04k | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); |
417 | 2.04k | buf.append(LOG4CXX_STR(": ")); |
418 | 2.04k | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); |
419 | 2.04k | appendQuotedEscapedString(buf, fileName); |
420 | 2.04k | buf.append(LOG4CXX_STR(",")); |
421 | 2.04k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
422 | | |
423 | 2.04k | if (m_priv->prettyPrint) |
424 | 1.30k | { |
425 | 1.30k | buf.append(m_priv->ppIndentL2); |
426 | 1.30k | } |
427 | | |
428 | 2.04k | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); |
429 | 2.04k | buf.append(LOG4CXX_STR(": ")); |
430 | 2.04k | LogString lineNumber; |
431 | 2.04k | StringHelper::toString(locInfo.getLineNumber(), p, lineNumber); |
432 | 2.04k | appendQuotedEscapedString(buf, lineNumber); |
433 | 2.04k | buf.append(LOG4CXX_STR(",")); |
434 | 2.04k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
435 | | |
436 | 2.04k | if (m_priv->prettyPrint) |
437 | 1.30k | { |
438 | 1.30k | buf.append(m_priv->ppIndentL2); |
439 | 1.30k | } |
440 | | |
441 | 2.04k | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); |
442 | 2.04k | buf.append(LOG4CXX_STR(": ")); |
443 | 2.04k | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); |
444 | 2.04k | appendQuotedEscapedString(buf, className); |
445 | 2.04k | buf.append(LOG4CXX_STR(",")); |
446 | 2.04k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
447 | | |
448 | 2.04k | if (m_priv->prettyPrint) |
449 | 1.30k | { |
450 | 1.30k | buf.append(m_priv->ppIndentL2); |
451 | 1.30k | } |
452 | | |
453 | 2.04k | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); |
454 | 2.04k | buf.append(LOG4CXX_STR(": ")); |
455 | 2.04k | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); |
456 | 2.04k | appendQuotedEscapedString(buf, methodName); |
457 | 2.04k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
458 | | |
459 | 2.04k | if (m_priv->prettyPrint) |
460 | 1.30k | { |
461 | 1.30k | buf.append(m_priv->ppIndentL1); |
462 | 1.30k | } |
463 | | |
464 | 2.04k | buf.append(LOG4CXX_STR("}")); |
465 | 2.04k | } 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 Line | Count | Source | 400 | 885 | { | 401 | 885 | if (m_priv->prettyPrint) | 402 | 605 | { | 403 | 605 | buf.append(m_priv->ppIndentL1); | 404 | 605 | } | 405 | | | 406 | 885 | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); | 407 | 885 | buf.append(LOG4CXX_STR(": {")); | 408 | 885 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 409 | 885 | const LocationInfo& locInfo = event->getLocationInformation(); | 410 | | | 411 | 885 | if (m_priv->prettyPrint) | 412 | 605 | { | 413 | 605 | buf.append(m_priv->ppIndentL2); | 414 | 605 | } | 415 | | | 416 | 885 | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); | 417 | 885 | buf.append(LOG4CXX_STR(": ")); | 418 | 885 | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); | 419 | 885 | appendQuotedEscapedString(buf, fileName); | 420 | 885 | buf.append(LOG4CXX_STR(",")); | 421 | 885 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 422 | | | 423 | 885 | if (m_priv->prettyPrint) | 424 | 605 | { | 425 | 605 | buf.append(m_priv->ppIndentL2); | 426 | 605 | } | 427 | | | 428 | 885 | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); | 429 | 885 | buf.append(LOG4CXX_STR(": ")); | 430 | 885 | LogString lineNumber; | 431 | 885 | StringHelper::toString(locInfo.getLineNumber(), p, lineNumber); | 432 | 885 | appendQuotedEscapedString(buf, lineNumber); | 433 | 885 | buf.append(LOG4CXX_STR(",")); | 434 | 885 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 435 | | | 436 | 885 | if (m_priv->prettyPrint) | 437 | 605 | { | 438 | 605 | buf.append(m_priv->ppIndentL2); | 439 | 605 | } | 440 | | | 441 | 885 | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); | 442 | 885 | buf.append(LOG4CXX_STR(": ")); | 443 | 885 | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); | 444 | 885 | appendQuotedEscapedString(buf, className); | 445 | 885 | buf.append(LOG4CXX_STR(",")); | 446 | 885 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 447 | | | 448 | 885 | if (m_priv->prettyPrint) | 449 | 605 | { | 450 | 605 | buf.append(m_priv->ppIndentL2); | 451 | 605 | } | 452 | | | 453 | 885 | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); | 454 | 885 | buf.append(LOG4CXX_STR(": ")); | 455 | 885 | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); | 456 | 885 | appendQuotedEscapedString(buf, methodName); | 457 | 885 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 458 | | | 459 | 885 | if (m_priv->prettyPrint) | 460 | 605 | { | 461 | 605 | buf.append(m_priv->ppIndentL1); | 462 | 605 | } | 463 | | | 464 | 885 | buf.append(LOG4CXX_STR("}")); | 465 | 885 | } |
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 Line | Count | Source | 400 | 1.16k | { | 401 | 1.16k | if (m_priv->prettyPrint) | 402 | 697 | { | 403 | 697 | buf.append(m_priv->ppIndentL1); | 404 | 697 | } | 405 | | | 406 | 1.16k | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); | 407 | 1.16k | buf.append(LOG4CXX_STR(": {")); | 408 | 1.16k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 409 | 1.16k | const LocationInfo& locInfo = event->getLocationInformation(); | 410 | | | 411 | 1.16k | if (m_priv->prettyPrint) | 412 | 697 | { | 413 | 697 | buf.append(m_priv->ppIndentL2); | 414 | 697 | } | 415 | | | 416 | 1.16k | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); | 417 | 1.16k | buf.append(LOG4CXX_STR(": ")); | 418 | 1.16k | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); | 419 | 1.16k | appendQuotedEscapedString(buf, fileName); | 420 | 1.16k | buf.append(LOG4CXX_STR(",")); | 421 | 1.16k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 422 | | | 423 | 1.16k | if (m_priv->prettyPrint) | 424 | 697 | { | 425 | 697 | buf.append(m_priv->ppIndentL2); | 426 | 697 | } | 427 | | | 428 | 1.16k | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); | 429 | 1.16k | buf.append(LOG4CXX_STR(": ")); | 430 | 1.16k | LogString lineNumber; | 431 | 1.16k | StringHelper::toString(locInfo.getLineNumber(), p, lineNumber); | 432 | 1.16k | appendQuotedEscapedString(buf, lineNumber); | 433 | 1.16k | buf.append(LOG4CXX_STR(",")); | 434 | 1.16k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 435 | | | 436 | 1.16k | if (m_priv->prettyPrint) | 437 | 697 | { | 438 | 697 | buf.append(m_priv->ppIndentL2); | 439 | 697 | } | 440 | | | 441 | 1.16k | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); | 442 | 1.16k | buf.append(LOG4CXX_STR(": ")); | 443 | 1.16k | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); | 444 | 1.16k | appendQuotedEscapedString(buf, className); | 445 | 1.16k | buf.append(LOG4CXX_STR(",")); | 446 | 1.16k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 447 | | | 448 | 1.16k | if (m_priv->prettyPrint) | 449 | 697 | { | 450 | 697 | buf.append(m_priv->ppIndentL2); | 451 | 697 | } | 452 | | | 453 | 1.16k | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); | 454 | 1.16k | buf.append(LOG4CXX_STR(": ")); | 455 | 1.16k | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); | 456 | 1.16k | appendQuotedEscapedString(buf, methodName); | 457 | 1.16k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 458 | | | 459 | 1.16k | if (m_priv->prettyPrint) | 460 | 697 | { | 461 | 697 | buf.append(m_priv->ppIndentL1); | 462 | 697 | } | 463 | | | 464 | 1.16k | buf.append(LOG4CXX_STR("}")); | 465 | 1.16k | } |
|
466 | | |