/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.86k | locationInfo(false), |
41 | 4.86k | prettyPrint(false), |
42 | 4.86k | ppIndentL1(LOG4CXX_STR(" ")), |
43 | 4.86k | ppIndentL2(LOG4CXX_STR(" ")), |
44 | 4.86k | expectedPatternLength(100), |
45 | 4.86k | 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.86k | m_priv(std::make_unique<JSONLayoutPrivate>()) |
68 | 4.86k | { |
69 | 4.86k | } Unexecuted instantiation: log4cxx::JSONLayout::JSONLayout() log4cxx::JSONLayout::JSONLayout() Line | Count | Source | 67 | 4.86k | m_priv(std::make_unique<JSONLayoutPrivate>()) | 68 | 4.86k | { | 69 | 4.86k | } |
|
70 | | |
71 | 4.86k | JSONLayout::~JSONLayout(){} |
72 | | |
73 | | void JSONLayout::setLocationInfo(bool locationInfoFlag) |
74 | 2.78k | { |
75 | 2.78k | m_priv->locationInfo = locationInfoFlag; |
76 | 2.78k | } |
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.35k | { |
85 | 2.35k | m_priv->prettyPrint = prettyPrintFlag; |
86 | 2.35k | } |
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.54k | { |
95 | 2.54k | m_priv->threadInfo = newValue; |
96 | 2.54k | } |
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.68k | { |
115 | 7.68k | if (StringHelper::equalsIgnoreCase(option, |
116 | 7.68k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) |
117 | 2.78k | { |
118 | 2.78k | setLocationInfo(OptionConverter::toBoolean(value, false)); |
119 | 2.78k | } |
120 | 4.90k | else if (StringHelper::equalsIgnoreCase(option, |
121 | 4.90k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) |
122 | 2.54k | { |
123 | 2.54k | setThreadInfo(OptionConverter::toBoolean(value, false)); |
124 | 2.54k | } |
125 | 2.35k | else if (StringHelper::equalsIgnoreCase(option, |
126 | 2.35k | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) |
127 | 2.35k | { |
128 | 2.35k | setPrettyPrint(OptionConverter::toBoolean(value, false)); |
129 | 2.35k | } |
130 | 7.68k | } 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.41k | { | 115 | 3.41k | if (StringHelper::equalsIgnoreCase(option, | 116 | 3.41k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) | 117 | 1.27k | { | 118 | 1.27k | setLocationInfo(OptionConverter::toBoolean(value, false)); | 119 | 1.27k | } | 120 | 2.14k | else if (StringHelper::equalsIgnoreCase(option, | 121 | 2.14k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) | 122 | 1.08k | { | 123 | 1.08k | setThreadInfo(OptionConverter::toBoolean(value, false)); | 124 | 1.08k | } | 125 | 1.05k | else if (StringHelper::equalsIgnoreCase(option, | 126 | 1.05k | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) | 127 | 1.05k | { | 128 | 1.05k | setPrettyPrint(OptionConverter::toBoolean(value, false)); | 129 | 1.05k | } | 130 | 3.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 | 114 | 4.26k | { | 115 | 4.26k | if (StringHelper::equalsIgnoreCase(option, | 116 | 4.26k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) | 117 | 1.50k | { | 118 | 1.50k | setLocationInfo(OptionConverter::toBoolean(value, false)); | 119 | 1.50k | } | 120 | 2.76k | else if (StringHelper::equalsIgnoreCase(option, | 121 | 2.76k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) | 122 | 1.46k | { | 123 | 1.46k | setThreadInfo(OptionConverter::toBoolean(value, false)); | 124 | 1.46k | } | 125 | 1.29k | else if (StringHelper::equalsIgnoreCase(option, | 126 | 1.29k | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) | 127 | 1.29k | { | 128 | 1.29k | setPrettyPrint(OptionConverter::toBoolean(value, false)); | 129 | 1.29k | } | 130 | 4.26k | } |
|
131 | | |
132 | | void JSONLayout::format( LOG4CXX_FORMAT_LAYOUT_FORMAL_PARAMETERS ) const |
133 | 4.86k | { |
134 | 4.86k | auto& lsMsg = event->getRenderedMessage(); |
135 | 4.86k | priv::reserveFormattedEvent(output, m_priv->expectedPatternLength, lsMsg.size()); |
136 | 4.86k | output.append(LOG4CXX_STR("{")); |
137 | 4.86k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
138 | | |
139 | 4.86k | if (m_priv->prettyPrint) |
140 | 2.35k | { |
141 | 2.35k | output.append(m_priv->ppIndentL1); |
142 | 2.35k | } |
143 | | |
144 | 4.86k | output.append(LOG4CXX_STR("\"timestamp\": \"")); |
145 | 4.86k | m_priv->dateFormat.format(output, event->getTimeStamp()); |
146 | 4.86k | output.append(LOG4CXX_STR("\",")); |
147 | 4.86k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
148 | | |
149 | 4.86k | if (m_priv->threadInfo) |
150 | 2.54k | { |
151 | 2.54k | if (m_priv->prettyPrint) |
152 | 1.60k | { |
153 | 1.60k | output.append(m_priv->ppIndentL1); |
154 | 1.60k | } |
155 | 2.54k | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); |
156 | 2.54k | output.append(LOG4CXX_STR(": ")); |
157 | 2.54k | appendQuotedEscapedString(output, event->getThreadName()); |
158 | 2.54k | output.append(LOG4CXX_STR(",")); |
159 | 2.54k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
160 | 2.54k | } |
161 | | |
162 | 4.86k | if (m_priv->prettyPrint) |
163 | 2.35k | { |
164 | 2.35k | output.append(m_priv->ppIndentL1); |
165 | 2.35k | } |
166 | | |
167 | 4.86k | output.append(LOG4CXX_STR("\"level\": ")); |
168 | 4.86k | LogString level; |
169 | 4.86k | event->getLevel()->toString(level); |
170 | 4.86k | appendQuotedEscapedString(output, level); |
171 | 4.86k | output.append(LOG4CXX_STR(",")); |
172 | 4.86k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
173 | | |
174 | 4.86k | if (m_priv->prettyPrint) |
175 | 2.35k | { |
176 | 2.35k | output.append(m_priv->ppIndentL1); |
177 | 2.35k | } |
178 | | |
179 | 4.86k | output.append(LOG4CXX_STR("\"logger\": ")); |
180 | 4.86k | appendQuotedEscapedString(output, event->getLoggerName()); |
181 | 4.86k | output.append(LOG4CXX_STR(",")); |
182 | 4.86k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
183 | | |
184 | 4.86k | if (m_priv->prettyPrint) |
185 | 2.35k | { |
186 | 2.35k | output.append(m_priv->ppIndentL1); |
187 | 2.35k | } |
188 | | |
189 | 4.86k | output.append(LOG4CXX_STR("\"message\": ")); |
190 | 4.86k | appendQuotedEscapedString(output, lsMsg); |
191 | | |
192 | 4.86k | appendSerializedMDC(output, event); |
193 | 4.86k | appendSerializedNDC(output, event); |
194 | | |
195 | 4.86k | if (m_priv->locationInfo) |
196 | 2.78k | { |
197 | 2.78k | output.append(LOG4CXX_STR(",")); |
198 | 2.78k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
199 | 2.78k | appendSerializedLocationInfo(output, event); |
200 | 2.78k | } |
201 | | |
202 | 4.86k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
203 | 4.86k | output.append(LOG4CXX_STR("}")); |
204 | 4.86k | output.append(LOG4CXX_EOL); |
205 | 4.86k | } 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.21k | { | 134 | 2.21k | auto& lsMsg = event->getRenderedMessage(); | 135 | 2.21k | priv::reserveFormattedEvent(output, m_priv->expectedPatternLength, lsMsg.size()); | 136 | 2.21k | output.append(LOG4CXX_STR("{")); | 137 | 2.21k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 138 | | | 139 | 2.21k | if (m_priv->prettyPrint) | 140 | 1.05k | { | 141 | 1.05k | output.append(m_priv->ppIndentL1); | 142 | 1.05k | } | 143 | | | 144 | 2.21k | output.append(LOG4CXX_STR("\"timestamp\": \"")); | 145 | 2.21k | m_priv->dateFormat.format(output, event->getTimeStamp()); | 146 | 2.21k | output.append(LOG4CXX_STR("\",")); | 147 | 2.21k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 148 | | | 149 | 2.21k | if (m_priv->threadInfo) | 150 | 1.08k | { | 151 | 1.08k | if (m_priv->prettyPrint) | 152 | 678 | { | 153 | 678 | output.append(m_priv->ppIndentL1); | 154 | 678 | } | 155 | 1.08k | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); | 156 | 1.08k | output.append(LOG4CXX_STR(": ")); | 157 | 1.08k | appendQuotedEscapedString(output, event->getThreadName()); | 158 | 1.08k | output.append(LOG4CXX_STR(",")); | 159 | 1.08k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 160 | 1.08k | } | 161 | | | 162 | 2.21k | if (m_priv->prettyPrint) | 163 | 1.05k | { | 164 | 1.05k | output.append(m_priv->ppIndentL1); | 165 | 1.05k | } | 166 | | | 167 | 2.21k | output.append(LOG4CXX_STR("\"level\": ")); | 168 | 2.21k | LogString level; | 169 | 2.21k | event->getLevel()->toString(level); | 170 | 2.21k | appendQuotedEscapedString(output, level); | 171 | 2.21k | output.append(LOG4CXX_STR(",")); | 172 | 2.21k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 173 | | | 174 | 2.21k | if (m_priv->prettyPrint) | 175 | 1.05k | { | 176 | 1.05k | output.append(m_priv->ppIndentL1); | 177 | 1.05k | } | 178 | | | 179 | 2.21k | output.append(LOG4CXX_STR("\"logger\": ")); | 180 | 2.21k | appendQuotedEscapedString(output, event->getLoggerName()); | 181 | 2.21k | output.append(LOG4CXX_STR(",")); | 182 | 2.21k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 183 | | | 184 | 2.21k | if (m_priv->prettyPrint) | 185 | 1.05k | { | 186 | 1.05k | output.append(m_priv->ppIndentL1); | 187 | 1.05k | } | 188 | | | 189 | 2.21k | output.append(LOG4CXX_STR("\"message\": ")); | 190 | 2.21k | appendQuotedEscapedString(output, lsMsg); | 191 | | | 192 | 2.21k | appendSerializedMDC(output, event); | 193 | 2.21k | appendSerializedNDC(output, event); | 194 | | | 195 | 2.21k | if (m_priv->locationInfo) | 196 | 1.27k | { | 197 | 1.27k | output.append(LOG4CXX_STR(",")); | 198 | 1.27k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 199 | 1.27k | appendSerializedLocationInfo(output, event); | 200 | 1.27k | } | 201 | | | 202 | 2.21k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 203 | 2.21k | output.append(LOG4CXX_STR("}")); | 204 | 2.21k | output.append(LOG4CXX_EOL); | 205 | 2.21k | } |
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.65k | { | 134 | 2.65k | auto& lsMsg = event->getRenderedMessage(); | 135 | 2.65k | priv::reserveFormattedEvent(output, m_priv->expectedPatternLength, lsMsg.size()); | 136 | 2.65k | output.append(LOG4CXX_STR("{")); | 137 | 2.65k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 138 | | | 139 | 2.65k | if (m_priv->prettyPrint) | 140 | 1.29k | { | 141 | 1.29k | output.append(m_priv->ppIndentL1); | 142 | 1.29k | } | 143 | | | 144 | 2.65k | output.append(LOG4CXX_STR("\"timestamp\": \"")); | 145 | 2.65k | m_priv->dateFormat.format(output, event->getTimeStamp()); | 146 | 2.65k | output.append(LOG4CXX_STR("\",")); | 147 | 2.65k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 148 | | | 149 | 2.65k | if (m_priv->threadInfo) | 150 | 1.46k | { | 151 | 1.46k | if (m_priv->prettyPrint) | 152 | 929 | { | 153 | 929 | output.append(m_priv->ppIndentL1); | 154 | 929 | } | 155 | 1.46k | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); | 156 | 1.46k | output.append(LOG4CXX_STR(": ")); | 157 | 1.46k | appendQuotedEscapedString(output, event->getThreadName()); | 158 | 1.46k | output.append(LOG4CXX_STR(",")); | 159 | 1.46k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 160 | 1.46k | } | 161 | | | 162 | 2.65k | if (m_priv->prettyPrint) | 163 | 1.29k | { | 164 | 1.29k | output.append(m_priv->ppIndentL1); | 165 | 1.29k | } | 166 | | | 167 | 2.65k | output.append(LOG4CXX_STR("\"level\": ")); | 168 | 2.65k | LogString level; | 169 | 2.65k | event->getLevel()->toString(level); | 170 | 2.65k | appendQuotedEscapedString(output, level); | 171 | 2.65k | output.append(LOG4CXX_STR(",")); | 172 | 2.65k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 173 | | | 174 | 2.65k | if (m_priv->prettyPrint) | 175 | 1.29k | { | 176 | 1.29k | output.append(m_priv->ppIndentL1); | 177 | 1.29k | } | 178 | | | 179 | 2.65k | output.append(LOG4CXX_STR("\"logger\": ")); | 180 | 2.65k | appendQuotedEscapedString(output, event->getLoggerName()); | 181 | 2.65k | output.append(LOG4CXX_STR(",")); | 182 | 2.65k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 183 | | | 184 | 2.65k | if (m_priv->prettyPrint) | 185 | 1.29k | { | 186 | 1.29k | output.append(m_priv->ppIndentL1); | 187 | 1.29k | } | 188 | | | 189 | 2.65k | output.append(LOG4CXX_STR("\"message\": ")); | 190 | 2.65k | appendQuotedEscapedString(output, lsMsg); | 191 | | | 192 | 2.65k | appendSerializedMDC(output, event); | 193 | 2.65k | appendSerializedNDC(output, event); | 194 | | | 195 | 2.65k | 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.65k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 203 | 2.65k | output.append(LOG4CXX_STR("}")); | 204 | 2.65k | output.append(LOG4CXX_EOL); | 205 | 2.65k | } |
|
206 | | |
207 | | void JSONLayout::appendQuotedEscapedString(LogString& buf, |
208 | | const LogString& input) const |
209 | 73.3k | { |
210 | 73.3k | appendItem(input, buf); |
211 | 73.3k | } 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 | 33.4k | { | 210 | 33.4k | appendItem(input, buf); | 211 | 33.4k | } |
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 | 39.8k | { | 210 | 39.8k | appendItem(input, buf); | 211 | 39.8k | } |
|
212 | | |
213 | | void JSONLayout::appendItem(const LogString& input, LogString& buf) |
214 | 73.3k | { |
215 | 73.3k | auto toHexDigit = [](int ch) -> int |
216 | 4.68M | { |
217 | 4.68M | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; |
218 | 4.68M | }; 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.96M | { | 217 | 1.96M | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 1.96M | }; |
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.72M | { | 217 | 2.72M | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 2.72M | }; |
|
219 | | /* add leading quote */ |
220 | 73.3k | buf.push_back(0x22); |
221 | | |
222 | 73.3k | auto start = input.begin(); |
223 | 2.25M | for (auto nextCodePoint = start; input.end() != nextCodePoint; ) |
224 | 2.18M | { |
225 | 2.18M | auto lastCodePoint = nextCodePoint; |
226 | 2.18M | auto ch = Transcoder::decode(input, nextCodePoint); |
227 | 2.18M | if (nextCodePoint == lastCodePoint) // failed to decode input? |
228 | 23.0k | { |
229 | | // Skip the undecodable run and keep escaping the remaining input |
230 | | // instead of discarding it; the run collapses to one replacement. |
231 | 84.9k | for (++nextCodePoint; nextCodePoint != input.end(); ++nextCodePoint) |
232 | 84.0k | { |
233 | 84.0k | auto probe = nextCodePoint; |
234 | 84.0k | Transcoder::decode(input, probe); |
235 | 84.0k | if (probe != nextCodePoint) // next unit starts a decodable sequence |
236 | 22.1k | break; |
237 | 84.0k | } |
238 | 23.0k | ch = 0xFFFD; // The Unicode replacement character |
239 | 23.0k | } |
240 | 2.15M | else if ((0xD800 <= ch && ch <= 0xDFFF) || 0x10FFFF < ch) |
241 | 0 | { |
242 | 0 | ch = 0xFFFD; // The Unicode replacement character |
243 | 0 | } |
244 | 2.15M | else if (0x22 == ch || 0x5c == ch) // double quote or backslash? |
245 | 14.7k | ; |
246 | 2.14M | else if (0x20 <= ch) // not a control character? |
247 | 891k | continue; |
248 | | |
249 | 1.28M | if (start != lastCodePoint) |
250 | 56.0k | buf.append(start, lastCodePoint); |
251 | 1.28M | start = nextCodePoint; |
252 | 1.28M | switch (ch) |
253 | 1.28M | { |
254 | 33.2k | case 0x08: |
255 | | /* \b backspace */ |
256 | 33.2k | buf.push_back(0x5c); |
257 | 33.2k | buf.push_back('b'); |
258 | 33.2k | break; |
259 | | |
260 | 8.80k | case 0x09: |
261 | | /* \t tab */ |
262 | 8.80k | buf.push_back(0x5c); |
263 | 8.80k | buf.push_back('t'); |
264 | 8.80k | break; |
265 | | |
266 | 22.9k | case 0x0a: |
267 | | /* \n newline */ |
268 | 22.9k | buf.push_back(0x5c); |
269 | 22.9k | buf.push_back('n'); |
270 | 22.9k | break; |
271 | | |
272 | 23.1k | case 0x0c: |
273 | | /* \f form feed */ |
274 | 23.1k | buf.push_back(0x5c); |
275 | 23.1k | buf.push_back('f'); |
276 | 23.1k | break; |
277 | | |
278 | 14.6k | case 0x0d: |
279 | | /* \r carriage return */ |
280 | 14.6k | buf.push_back(0x5c); |
281 | 14.6k | buf.push_back('r'); |
282 | 14.6k | break; |
283 | | |
284 | 8.81k | case 0x22: |
285 | | /* \" double quote */ |
286 | 8.81k | buf.push_back(0x5c); |
287 | 8.81k | buf.push_back(0x22); |
288 | 8.81k | break; |
289 | | |
290 | 5.90k | case 0x5c: |
291 | | /* \\ backslash */ |
292 | 5.90k | buf.push_back(0x5c); |
293 | 5.90k | buf.push_back(0x5c); |
294 | 5.90k | break; |
295 | | |
296 | 1.17M | default: |
297 | 1.17M | buf.push_back(0x5c); |
298 | 1.17M | buf.push_back(0x75); // 'u' |
299 | 1.17M | buf.push_back(toHexDigit((ch & 0xF000) >> 12)); |
300 | 1.17M | buf.push_back(toHexDigit((ch & 0xF00) >> 8)); |
301 | 1.17M | buf.push_back(toHexDigit((ch & 0xF0) >> 4)); |
302 | 1.17M | buf.push_back(toHexDigit(ch & 0xF)); |
303 | 1.17M | break; |
304 | 1.28M | } |
305 | 1.28M | } |
306 | 73.3k | buf.append(start, input.end()); |
307 | | |
308 | | /* add trailing quote */ |
309 | 73.3k | buf.push_back(0x22); |
310 | 73.3k | } 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 | 33.4k | { | 215 | 33.4k | auto toHexDigit = [](int ch) -> int | 216 | 33.4k | { | 217 | 33.4k | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 33.4k | }; | 219 | | /* add leading quote */ | 220 | 33.4k | buf.push_back(0x22); | 221 | | | 222 | 33.4k | auto start = input.begin(); | 223 | 898k | for (auto nextCodePoint = start; input.end() != nextCodePoint; ) | 224 | 864k | { | 225 | 864k | auto lastCodePoint = nextCodePoint; | 226 | 864k | auto ch = Transcoder::decode(input, nextCodePoint); | 227 | 864k | if (nextCodePoint == lastCodePoint) // failed to decode input? | 228 | 23.0k | { | 229 | | // Skip the undecodable run and keep escaping the remaining input | 230 | | // instead of discarding it; the run collapses to one replacement. | 231 | 84.9k | for (++nextCodePoint; nextCodePoint != input.end(); ++nextCodePoint) | 232 | 84.0k | { | 233 | 84.0k | auto probe = nextCodePoint; | 234 | 84.0k | Transcoder::decode(input, probe); | 235 | 84.0k | if (probe != nextCodePoint) // next unit starts a decodable sequence | 236 | 22.1k | break; | 237 | 84.0k | } | 238 | 23.0k | ch = 0xFFFD; // The Unicode replacement character | 239 | 23.0k | } | 240 | 841k | else if ((0xD800 <= ch && ch <= 0xDFFF) || 0x10FFFF < ch) | 241 | 0 | { | 242 | 0 | ch = 0xFFFD; // The Unicode replacement character | 243 | 0 | } | 244 | 841k | else if (0x22 == ch || 0x5c == ch) // double quote or backslash? | 245 | 6.70k | ; | 246 | 835k | else if (0x20 <= ch) // not a control character? | 247 | 349k | continue; | 248 | | | 249 | 515k | if (start != lastCodePoint) | 250 | 28.0k | buf.append(start, lastCodePoint); | 251 | 515k | start = nextCodePoint; | 252 | 515k | switch (ch) | 253 | 515k | { | 254 | 3.13k | case 0x08: | 255 | | /* \b backspace */ | 256 | 3.13k | buf.push_back(0x5c); | 257 | 3.13k | buf.push_back('b'); | 258 | 3.13k | break; | 259 | | | 260 | 2.01k | case 0x09: | 261 | | /* \t tab */ | 262 | 2.01k | buf.push_back(0x5c); | 263 | 2.01k | buf.push_back('t'); | 264 | 2.01k | break; | 265 | | | 266 | 9.45k | case 0x0a: | 267 | | /* \n newline */ | 268 | 9.45k | buf.push_back(0x5c); | 269 | 9.45k | buf.push_back('n'); | 270 | 9.45k | break; | 271 | | | 272 | 1.20k | case 0x0c: | 273 | | /* \f form feed */ | 274 | 1.20k | buf.push_back(0x5c); | 275 | 1.20k | buf.push_back('f'); | 276 | 1.20k | break; | 277 | | | 278 | 2.57k | case 0x0d: | 279 | | /* \r carriage return */ | 280 | 2.57k | buf.push_back(0x5c); | 281 | 2.57k | buf.push_back('r'); | 282 | 2.57k | break; | 283 | | | 284 | 4.27k | case 0x22: | 285 | | /* \" double quote */ | 286 | 4.27k | buf.push_back(0x5c); | 287 | 4.27k | buf.push_back(0x22); | 288 | 4.27k | break; | 289 | | | 290 | 2.42k | case 0x5c: | 291 | | /* \\ backslash */ | 292 | 2.42k | buf.push_back(0x5c); | 293 | 2.42k | buf.push_back(0x5c); | 294 | 2.42k | break; | 295 | | | 296 | 490k | default: | 297 | 490k | buf.push_back(0x5c); | 298 | 490k | buf.push_back(0x75); // 'u' | 299 | 490k | buf.push_back(toHexDigit((ch & 0xF000) >> 12)); | 300 | 490k | buf.push_back(toHexDigit((ch & 0xF00) >> 8)); | 301 | 490k | buf.push_back(toHexDigit((ch & 0xF0) >> 4)); | 302 | 490k | buf.push_back(toHexDigit(ch & 0xF)); | 303 | 490k | break; | 304 | 515k | } | 305 | 515k | } | 306 | 33.4k | buf.append(start, input.end()); | 307 | | | 308 | | /* add trailing quote */ | 309 | 33.4k | buf.push_back(0x22); | 310 | 33.4k | } |
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 | 39.8k | { | 215 | 39.8k | auto toHexDigit = [](int ch) -> int | 216 | 39.8k | { | 217 | 39.8k | return (10 <= ch ? (0x61 - 10) : 0x30) + ch; | 218 | 39.8k | }; | 219 | | /* add leading quote */ | 220 | 39.8k | buf.push_back(0x22); | 221 | | | 222 | 39.8k | auto start = input.begin(); | 223 | 1.35M | for (auto nextCodePoint = start; input.end() != nextCodePoint; ) | 224 | 1.31M | { | 225 | 1.31M | auto lastCodePoint = nextCodePoint; | 226 | 1.31M | auto ch = Transcoder::decode(input, nextCodePoint); | 227 | 1.31M | if (nextCodePoint == lastCodePoint) // failed to decode input? | 228 | 0 | { | 229 | | // Skip the undecodable run and keep escaping the remaining input | 230 | | // instead of discarding it; the run collapses to one replacement. | 231 | 0 | for (++nextCodePoint; nextCodePoint != input.end(); ++nextCodePoint) | 232 | 0 | { | 233 | 0 | auto probe = nextCodePoint; | 234 | 0 | Transcoder::decode(input, probe); | 235 | 0 | if (probe != nextCodePoint) // next unit starts a decodable sequence | 236 | 0 | break; | 237 | 0 | } | 238 | 0 | ch = 0xFFFD; // The Unicode replacement character | 239 | 0 | } | 240 | 1.31M | else if ((0xD800 <= ch && ch <= 0xDFFF) || 0x10FFFF < ch) | 241 | 0 | { | 242 | 0 | ch = 0xFFFD; // The Unicode replacement character | 243 | 0 | } | 244 | 1.31M | else if (0x22 == ch || 0x5c == ch) // double quote or backslash? | 245 | 8.00k | ; | 246 | 1.30M | else if (0x20 <= ch) // not a control character? | 247 | 542k | continue; | 248 | | | 249 | 773k | if (start != lastCodePoint) | 250 | 28.0k | buf.append(start, lastCodePoint); | 251 | 773k | start = nextCodePoint; | 252 | 773k | switch (ch) | 253 | 773k | { | 254 | 30.1k | case 0x08: | 255 | | /* \b backspace */ | 256 | 30.1k | buf.push_back(0x5c); | 257 | 30.1k | buf.push_back('b'); | 258 | 30.1k | break; | 259 | | | 260 | 6.79k | case 0x09: | 261 | | /* \t tab */ | 262 | 6.79k | buf.push_back(0x5c); | 263 | 6.79k | buf.push_back('t'); | 264 | 6.79k | break; | 265 | | | 266 | 13.4k | case 0x0a: | 267 | | /* \n newline */ | 268 | 13.4k | buf.push_back(0x5c); | 269 | 13.4k | buf.push_back('n'); | 270 | 13.4k | break; | 271 | | | 272 | 21.8k | case 0x0c: | 273 | | /* \f form feed */ | 274 | 21.8k | buf.push_back(0x5c); | 275 | 21.8k | buf.push_back('f'); | 276 | 21.8k | break; | 277 | | | 278 | 12.1k | case 0x0d: | 279 | | /* \r carriage return */ | 280 | 12.1k | buf.push_back(0x5c); | 281 | 12.1k | buf.push_back('r'); | 282 | 12.1k | break; | 283 | | | 284 | 4.53k | case 0x22: | 285 | | /* \" double quote */ | 286 | 4.53k | buf.push_back(0x5c); | 287 | 4.53k | buf.push_back(0x22); | 288 | 4.53k | break; | 289 | | | 290 | 3.47k | case 0x5c: | 291 | | /* \\ backslash */ | 292 | 3.47k | buf.push_back(0x5c); | 293 | 3.47k | buf.push_back(0x5c); | 294 | 3.47k | break; | 295 | | | 296 | 681k | default: | 297 | 681k | buf.push_back(0x5c); | 298 | 681k | buf.push_back(0x75); // 'u' | 299 | 681k | buf.push_back(toHexDigit((ch & 0xF000) >> 12)); | 300 | 681k | buf.push_back(toHexDigit((ch & 0xF00) >> 8)); | 301 | 681k | buf.push_back(toHexDigit((ch & 0xF0) >> 4)); | 302 | 681k | buf.push_back(toHexDigit(ch & 0xF)); | 303 | 681k | break; | 304 | 773k | } | 305 | 773k | } | 306 | 39.8k | buf.append(start, input.end()); | 307 | | | 308 | | /* add trailing quote */ | 309 | 39.8k | buf.push_back(0x22); | 310 | 39.8k | } |
|
311 | | |
312 | | void JSONLayout::appendSerializedMDC(LogString& buf, |
313 | | const LoggingEventPtr& event) const |
314 | 4.86k | { |
315 | 4.86k | LoggingEvent::KeySet keys = event->getMDCKeySet(); |
316 | | |
317 | 4.86k | if (keys.empty()) |
318 | 0 | { |
319 | 0 | return; |
320 | 0 | } |
321 | | |
322 | 4.86k | buf.append(LOG4CXX_STR(",")); |
323 | 4.86k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
324 | | |
325 | 4.86k | if (m_priv->prettyPrint) |
326 | 2.35k | { |
327 | 2.35k | buf.append(m_priv->ppIndentL1); |
328 | 2.35k | } |
329 | | |
330 | 4.86k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); |
331 | 4.86k | buf.append(LOG4CXX_STR(": {")); |
332 | 4.86k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
333 | | |
334 | 4.86k | for (LoggingEvent::KeySet::iterator it = keys.begin(); |
335 | 11.8k | it != keys.end(); ++it) |
336 | 7.01k | { |
337 | 7.01k | if (m_priv->prettyPrint) |
338 | 3.60k | { |
339 | 3.60k | buf.append(m_priv->ppIndentL2); |
340 | 3.60k | } |
341 | | |
342 | 7.01k | appendQuotedEscapedString(buf, *it); |
343 | 7.01k | buf.append(LOG4CXX_STR(": ")); |
344 | 7.01k | LogString value; |
345 | 7.01k | event->getMDC(*it, value); |
346 | 7.01k | appendQuotedEscapedString(buf, value); |
347 | | |
348 | | /* if this isn't the last k:v pair, we need a comma */ |
349 | 7.01k | if (it + 1 != keys.end()) |
350 | 2.14k | { |
351 | 2.14k | buf.append(LOG4CXX_STR(",")); |
352 | 2.14k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
353 | 2.14k | } |
354 | 4.86k | else |
355 | 4.86k | { |
356 | 4.86k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
357 | 4.86k | } |
358 | 7.01k | } |
359 | | |
360 | 4.86k | if (m_priv->prettyPrint) |
361 | 2.35k | { |
362 | 2.35k | buf.append(m_priv->ppIndentL1); |
363 | 2.35k | } |
364 | | |
365 | 4.86k | buf.append(LOG4CXX_STR("}")); |
366 | 4.86k | } 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 | 314 | 2.21k | { | 315 | 2.21k | LoggingEvent::KeySet keys = event->getMDCKeySet(); | 316 | | | 317 | 2.21k | if (keys.empty()) | 318 | 0 | { | 319 | 0 | return; | 320 | 0 | } | 321 | | | 322 | 2.21k | buf.append(LOG4CXX_STR(",")); | 323 | 2.21k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 324 | | | 325 | 2.21k | if (m_priv->prettyPrint) | 326 | 1.05k | { | 327 | 1.05k | buf.append(m_priv->ppIndentL1); | 328 | 1.05k | } | 329 | | | 330 | 2.21k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); | 331 | 2.21k | buf.append(LOG4CXX_STR(": {")); | 332 | 2.21k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 333 | | | 334 | 2.21k | for (LoggingEvent::KeySet::iterator it = keys.begin(); | 335 | 5.49k | it != keys.end(); ++it) | 336 | 3.28k | { | 337 | 3.28k | if (m_priv->prettyPrint) | 338 | 1.65k | { | 339 | 1.65k | buf.append(m_priv->ppIndentL2); | 340 | 1.65k | } | 341 | | | 342 | 3.28k | appendQuotedEscapedString(buf, *it); | 343 | 3.28k | buf.append(LOG4CXX_STR(": ")); | 344 | 3.28k | LogString value; | 345 | 3.28k | event->getMDC(*it, value); | 346 | 3.28k | appendQuotedEscapedString(buf, value); | 347 | | | 348 | | /* if this isn't the last k:v pair, we need a comma */ | 349 | 3.28k | if (it + 1 != keys.end()) | 350 | 1.06k | { | 351 | 1.06k | buf.append(LOG4CXX_STR(",")); | 352 | 1.06k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 353 | 1.06k | } | 354 | 2.21k | else | 355 | 2.21k | { | 356 | 2.21k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 357 | 2.21k | } | 358 | 3.28k | } | 359 | | | 360 | 2.21k | if (m_priv->prettyPrint) | 361 | 1.05k | { | 362 | 1.05k | buf.append(m_priv->ppIndentL1); | 363 | 1.05k | } | 364 | | | 365 | 2.21k | buf.append(LOG4CXX_STR("}")); | 366 | 2.21k | } |
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 | 314 | 2.65k | { | 315 | 2.65k | LoggingEvent::KeySet keys = event->getMDCKeySet(); | 316 | | | 317 | 2.65k | if (keys.empty()) | 318 | 0 | { | 319 | 0 | return; | 320 | 0 | } | 321 | | | 322 | 2.65k | buf.append(LOG4CXX_STR(",")); | 323 | 2.65k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 324 | | | 325 | 2.65k | if (m_priv->prettyPrint) | 326 | 1.29k | { | 327 | 1.29k | buf.append(m_priv->ppIndentL1); | 328 | 1.29k | } | 329 | | | 330 | 2.65k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); | 331 | 2.65k | buf.append(LOG4CXX_STR(": {")); | 332 | 2.65k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 333 | | | 334 | 2.65k | for (LoggingEvent::KeySet::iterator it = keys.begin(); | 335 | 6.38k | it != keys.end(); ++it) | 336 | 3.73k | { | 337 | 3.73k | if (m_priv->prettyPrint) | 338 | 1.95k | { | 339 | 1.95k | buf.append(m_priv->ppIndentL2); | 340 | 1.95k | } | 341 | | | 342 | 3.73k | appendQuotedEscapedString(buf, *it); | 343 | 3.73k | buf.append(LOG4CXX_STR(": ")); | 344 | 3.73k | LogString value; | 345 | 3.73k | event->getMDC(*it, value); | 346 | 3.73k | appendQuotedEscapedString(buf, value); | 347 | | | 348 | | /* if this isn't the last k:v pair, we need a comma */ | 349 | 3.73k | if (it + 1 != keys.end()) | 350 | 1.07k | { | 351 | 1.07k | buf.append(LOG4CXX_STR(",")); | 352 | 1.07k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 353 | 1.07k | } | 354 | 2.65k | else | 355 | 2.65k | { | 356 | 2.65k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 357 | 2.65k | } | 358 | 3.73k | } | 359 | | | 360 | 2.65k | if (m_priv->prettyPrint) | 361 | 1.29k | { | 362 | 1.29k | buf.append(m_priv->ppIndentL1); | 363 | 1.29k | } | 364 | | | 365 | 2.65k | buf.append(LOG4CXX_STR("}")); | 366 | 2.65k | } |
|
367 | | |
368 | | void JSONLayout::appendSerializedNDC(LogString& buf, |
369 | | const LoggingEventPtr& event) const |
370 | 4.86k | { |
371 | 4.86k | LogString ndcVal; |
372 | | |
373 | 4.86k | if (!event->getNDC(ndcVal)) |
374 | 0 | { |
375 | 0 | return; |
376 | 0 | } |
377 | | |
378 | 4.86k | buf.append(LOG4CXX_STR(",")); |
379 | 4.86k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
380 | | |
381 | 4.86k | if (m_priv->prettyPrint) |
382 | 2.35k | { |
383 | 2.35k | buf.append(m_priv->ppIndentL1); |
384 | 2.35k | } |
385 | | |
386 | 4.86k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); |
387 | 4.86k | buf.append(LOG4CXX_STR(": [")); |
388 | 4.86k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
389 | | |
390 | 4.86k | if (m_priv->prettyPrint) |
391 | 2.35k | { |
392 | 2.35k | buf.append(m_priv->ppIndentL2); |
393 | 2.35k | } |
394 | | |
395 | 4.86k | appendQuotedEscapedString(buf, ndcVal); |
396 | 4.86k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
397 | | |
398 | 4.86k | if (m_priv->prettyPrint) |
399 | 2.35k | { |
400 | 2.35k | buf.append(m_priv->ppIndentL1); |
401 | 2.35k | } |
402 | | |
403 | 4.86k | buf.append(LOG4CXX_STR("]")); |
404 | 4.86k | } 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 | 370 | 2.21k | { | 371 | 2.21k | LogString ndcVal; | 372 | | | 373 | 2.21k | if (!event->getNDC(ndcVal)) | 374 | 0 | { | 375 | 0 | return; | 376 | 0 | } | 377 | | | 378 | 2.21k | buf.append(LOG4CXX_STR(",")); | 379 | 2.21k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 380 | | | 381 | 2.21k | if (m_priv->prettyPrint) | 382 | 1.05k | { | 383 | 1.05k | buf.append(m_priv->ppIndentL1); | 384 | 1.05k | } | 385 | | | 386 | 2.21k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); | 387 | 2.21k | buf.append(LOG4CXX_STR(": [")); | 388 | 2.21k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 389 | | | 390 | 2.21k | if (m_priv->prettyPrint) | 391 | 1.05k | { | 392 | 1.05k | buf.append(m_priv->ppIndentL2); | 393 | 1.05k | } | 394 | | | 395 | 2.21k | appendQuotedEscapedString(buf, ndcVal); | 396 | 2.21k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 397 | | | 398 | 2.21k | if (m_priv->prettyPrint) | 399 | 1.05k | { | 400 | 1.05k | buf.append(m_priv->ppIndentL1); | 401 | 1.05k | } | 402 | | | 403 | 2.21k | buf.append(LOG4CXX_STR("]")); | 404 | 2.21k | } |
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 | 370 | 2.65k | { | 371 | 2.65k | LogString ndcVal; | 372 | | | 373 | 2.65k | if (!event->getNDC(ndcVal)) | 374 | 0 | { | 375 | 0 | return; | 376 | 0 | } | 377 | | | 378 | 2.65k | buf.append(LOG4CXX_STR(",")); | 379 | 2.65k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 380 | | | 381 | 2.65k | if (m_priv->prettyPrint) | 382 | 1.29k | { | 383 | 1.29k | buf.append(m_priv->ppIndentL1); | 384 | 1.29k | } | 385 | | | 386 | 2.65k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); | 387 | 2.65k | buf.append(LOG4CXX_STR(": [")); | 388 | 2.65k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 389 | | | 390 | 2.65k | if (m_priv->prettyPrint) | 391 | 1.29k | { | 392 | 1.29k | buf.append(m_priv->ppIndentL2); | 393 | 1.29k | } | 394 | | | 395 | 2.65k | appendQuotedEscapedString(buf, ndcVal); | 396 | 2.65k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 397 | | | 398 | 2.65k | if (m_priv->prettyPrint) | 399 | 1.29k | { | 400 | 1.29k | buf.append(m_priv->ppIndentL1); | 401 | 1.29k | } | 402 | | | 403 | 2.65k | buf.append(LOG4CXX_STR("]")); | 404 | 2.65k | } |
|
405 | | |
406 | | void JSONLayout::appendSerializedLocationInfo(LogString& buf, const LoggingEventPtr& event) const |
407 | 2.78k | { |
408 | 2.78k | if (m_priv->prettyPrint) |
409 | 1.67k | { |
410 | 1.67k | buf.append(m_priv->ppIndentL1); |
411 | 1.67k | } |
412 | | |
413 | 2.78k | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); |
414 | 2.78k | buf.append(LOG4CXX_STR(": {")); |
415 | 2.78k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
416 | 2.78k | const LocationInfo& locInfo = event->getLocationInformation(); |
417 | | |
418 | 2.78k | if (m_priv->prettyPrint) |
419 | 1.67k | { |
420 | 1.67k | buf.append(m_priv->ppIndentL2); |
421 | 1.67k | } |
422 | | |
423 | 2.78k | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); |
424 | 2.78k | buf.append(LOG4CXX_STR(": ")); |
425 | 2.78k | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); |
426 | 2.78k | appendQuotedEscapedString(buf, fileName); |
427 | 2.78k | buf.append(LOG4CXX_STR(",")); |
428 | 2.78k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
429 | | |
430 | 2.78k | if (m_priv->prettyPrint) |
431 | 1.67k | { |
432 | 1.67k | buf.append(m_priv->ppIndentL2); |
433 | 1.67k | } |
434 | | |
435 | 2.78k | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); |
436 | 2.78k | buf.append(LOG4CXX_STR(": ")); |
437 | 2.78k | LogString lineNumber; |
438 | 2.78k | StringHelper::toString(locInfo.getLineNumber(), lineNumber); |
439 | 2.78k | appendQuotedEscapedString(buf, lineNumber); |
440 | 2.78k | buf.append(LOG4CXX_STR(",")); |
441 | 2.78k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
442 | | |
443 | 2.78k | if (m_priv->prettyPrint) |
444 | 1.67k | { |
445 | 1.67k | buf.append(m_priv->ppIndentL2); |
446 | 1.67k | } |
447 | | |
448 | 2.78k | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); |
449 | 2.78k | buf.append(LOG4CXX_STR(": ")); |
450 | 2.78k | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); |
451 | 2.78k | appendQuotedEscapedString(buf, className); |
452 | 2.78k | buf.append(LOG4CXX_STR(",")); |
453 | 2.78k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
454 | | |
455 | 2.78k | if (m_priv->prettyPrint) |
456 | 1.67k | { |
457 | 1.67k | buf.append(m_priv->ppIndentL2); |
458 | 1.67k | } |
459 | | |
460 | 2.78k | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); |
461 | 2.78k | buf.append(LOG4CXX_STR(": ")); |
462 | 2.78k | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); |
463 | 2.78k | appendQuotedEscapedString(buf, methodName); |
464 | 2.78k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
465 | | |
466 | 2.78k | if (m_priv->prettyPrint) |
467 | 1.67k | { |
468 | 1.67k | buf.append(m_priv->ppIndentL1); |
469 | 1.67k | } |
470 | | |
471 | 2.78k | buf.append(LOG4CXX_STR("}")); |
472 | 2.78k | } 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 | 407 | 1.27k | { | 408 | 1.27k | if (m_priv->prettyPrint) | 409 | 742 | { | 410 | 742 | buf.append(m_priv->ppIndentL1); | 411 | 742 | } | 412 | | | 413 | 1.27k | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); | 414 | 1.27k | buf.append(LOG4CXX_STR(": {")); | 415 | 1.27k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 416 | 1.27k | const LocationInfo& locInfo = event->getLocationInformation(); | 417 | | | 418 | 1.27k | if (m_priv->prettyPrint) | 419 | 742 | { | 420 | 742 | buf.append(m_priv->ppIndentL2); | 421 | 742 | } | 422 | | | 423 | 1.27k | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); | 424 | 1.27k | buf.append(LOG4CXX_STR(": ")); | 425 | 1.27k | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); | 426 | 1.27k | appendQuotedEscapedString(buf, fileName); | 427 | 1.27k | buf.append(LOG4CXX_STR(",")); | 428 | 1.27k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 429 | | | 430 | 1.27k | if (m_priv->prettyPrint) | 431 | 742 | { | 432 | 742 | buf.append(m_priv->ppIndentL2); | 433 | 742 | } | 434 | | | 435 | 1.27k | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); | 436 | 1.27k | buf.append(LOG4CXX_STR(": ")); | 437 | 1.27k | LogString lineNumber; | 438 | 1.27k | StringHelper::toString(locInfo.getLineNumber(), lineNumber); | 439 | 1.27k | appendQuotedEscapedString(buf, lineNumber); | 440 | 1.27k | buf.append(LOG4CXX_STR(",")); | 441 | 1.27k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 442 | | | 443 | 1.27k | if (m_priv->prettyPrint) | 444 | 742 | { | 445 | 742 | buf.append(m_priv->ppIndentL2); | 446 | 742 | } | 447 | | | 448 | 1.27k | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); | 449 | 1.27k | buf.append(LOG4CXX_STR(": ")); | 450 | 1.27k | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); | 451 | 1.27k | appendQuotedEscapedString(buf, className); | 452 | 1.27k | buf.append(LOG4CXX_STR(",")); | 453 | 1.27k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 454 | | | 455 | 1.27k | if (m_priv->prettyPrint) | 456 | 742 | { | 457 | 742 | buf.append(m_priv->ppIndentL2); | 458 | 742 | } | 459 | | | 460 | 1.27k | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); | 461 | 1.27k | buf.append(LOG4CXX_STR(": ")); | 462 | 1.27k | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); | 463 | 1.27k | appendQuotedEscapedString(buf, methodName); | 464 | 1.27k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 465 | | | 466 | 1.27k | if (m_priv->prettyPrint) | 467 | 742 | { | 468 | 742 | buf.append(m_priv->ppIndentL1); | 469 | 742 | } | 470 | | | 471 | 1.27k | buf.append(LOG4CXX_STR("}")); | 472 | 1.27k | } |
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 | 407 | 1.50k | { | 408 | 1.50k | if (m_priv->prettyPrint) | 409 | 937 | { | 410 | 937 | buf.append(m_priv->ppIndentL1); | 411 | 937 | } | 412 | | | 413 | 1.50k | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); | 414 | 1.50k | buf.append(LOG4CXX_STR(": {")); | 415 | 1.50k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 416 | 1.50k | const LocationInfo& locInfo = event->getLocationInformation(); | 417 | | | 418 | 1.50k | if (m_priv->prettyPrint) | 419 | 937 | { | 420 | 937 | buf.append(m_priv->ppIndentL2); | 421 | 937 | } | 422 | | | 423 | 1.50k | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); | 424 | 1.50k | buf.append(LOG4CXX_STR(": ")); | 425 | 1.50k | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); | 426 | 1.50k | appendQuotedEscapedString(buf, fileName); | 427 | 1.50k | buf.append(LOG4CXX_STR(",")); | 428 | 1.50k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 429 | | | 430 | 1.50k | if (m_priv->prettyPrint) | 431 | 937 | { | 432 | 937 | buf.append(m_priv->ppIndentL2); | 433 | 937 | } | 434 | | | 435 | 1.50k | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); | 436 | 1.50k | buf.append(LOG4CXX_STR(": ")); | 437 | 1.50k | LogString lineNumber; | 438 | 1.50k | StringHelper::toString(locInfo.getLineNumber(), lineNumber); | 439 | 1.50k | appendQuotedEscapedString(buf, lineNumber); | 440 | 1.50k | buf.append(LOG4CXX_STR(",")); | 441 | 1.50k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 442 | | | 443 | 1.50k | if (m_priv->prettyPrint) | 444 | 937 | { | 445 | 937 | buf.append(m_priv->ppIndentL2); | 446 | 937 | } | 447 | | | 448 | 1.50k | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); | 449 | 1.50k | buf.append(LOG4CXX_STR(": ")); | 450 | 1.50k | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); | 451 | 1.50k | appendQuotedEscapedString(buf, className); | 452 | 1.50k | buf.append(LOG4CXX_STR(",")); | 453 | 1.50k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 454 | | | 455 | 1.50k | if (m_priv->prettyPrint) | 456 | 937 | { | 457 | 937 | buf.append(m_priv->ppIndentL2); | 458 | 937 | } | 459 | | | 460 | 1.50k | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); | 461 | 1.50k | buf.append(LOG4CXX_STR(": ")); | 462 | 1.50k | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); | 463 | 1.50k | appendQuotedEscapedString(buf, methodName); | 464 | 1.50k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 465 | | | 466 | 1.50k | if (m_priv->prettyPrint) | 467 | 937 | { | 468 | 937 | buf.append(m_priv->ppIndentL1); | 469 | 937 | } | 470 | | | 471 | 1.50k | buf.append(LOG4CXX_STR("}")); | 472 | 1.50k | } |
|
473 | | |
474 | | #if LOG4CXX_ABI_VERSION <= 15 |
475 | | void JSONLayout::appendSerializedLocationInfo(LogString& buf, |
476 | | const LoggingEventPtr& event, Pool& p) const |
477 | 0 | { |
478 | 0 | appendSerializedLocationInfo(buf, event); |
479 | 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 |
480 | | #endif |