/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/iso8601dateformat.h> |
24 | | #include <log4cxx/helpers/stringhelper.h> |
25 | | #include <log4cxx/helpers/transcoder.h> |
26 | | |
27 | | #include <string.h> |
28 | | |
29 | | using namespace LOG4CXX_NS; |
30 | | using namespace LOG4CXX_NS::helpers; |
31 | | using namespace LOG4CXX_NS::spi; |
32 | | |
33 | | IMPLEMENT_LOG4CXX_OBJECT(JSONLayout) |
34 | | |
35 | | struct JSONLayout::JSONLayoutPrivate |
36 | | { |
37 | | JSONLayoutPrivate() : |
38 | 2.88k | locationInfo(false), |
39 | 2.88k | prettyPrint(false), |
40 | 2.88k | dateFormat(), |
41 | 2.88k | ppIndentL1(LOG4CXX_STR(" ")), |
42 | 2.88k | ppIndentL2(LOG4CXX_STR(" ")), |
43 | 2.88k | expectedPatternLength(100), |
44 | 2.88k | threadInfo(false) {} |
45 | | |
46 | | // Print no location info by default |
47 | | bool locationInfo; //= false |
48 | | bool prettyPrint; //= false |
49 | | |
50 | | helpers::ISO8601DateFormat dateFormat; |
51 | | |
52 | | LogString ppIndentL1; |
53 | | LogString ppIndentL2; |
54 | | |
55 | | // Expected length of a formatted event excluding the message text |
56 | | size_t expectedPatternLength; |
57 | | |
58 | | // Thread info is not included by default |
59 | | bool threadInfo; //= false |
60 | | }; |
61 | | |
62 | | JSONLayout::JSONLayout() : |
63 | 2.88k | m_priv(std::make_unique<JSONLayoutPrivate>()) |
64 | 2.88k | { |
65 | 2.88k | } Unexecuted instantiation: log4cxx::JSONLayout::JSONLayout() log4cxx::JSONLayout::JSONLayout() Line | Count | Source | 63 | 2.88k | m_priv(std::make_unique<JSONLayoutPrivate>()) | 64 | 2.88k | { | 65 | 2.88k | } |
|
66 | | |
67 | 2.88k | JSONLayout::~JSONLayout(){} |
68 | | |
69 | | void JSONLayout::setLocationInfo(bool locationInfoFlag) |
70 | 1.87k | { |
71 | 1.87k | m_priv->locationInfo = locationInfoFlag; |
72 | 1.87k | } |
73 | | |
74 | | bool JSONLayout::getLocationInfo() const |
75 | 0 | { |
76 | 0 | return m_priv->locationInfo; |
77 | 0 | } |
78 | | |
79 | | void JSONLayout::setPrettyPrint(bool prettyPrintFlag) |
80 | 1.74k | { |
81 | 1.74k | m_priv->prettyPrint = prettyPrintFlag; |
82 | 1.74k | } |
83 | | |
84 | | bool JSONLayout::getPrettyPrint() const |
85 | 0 | { |
86 | 0 | return m_priv->prettyPrint; |
87 | 0 | } |
88 | | |
89 | | void JSONLayout::setThreadInfo(bool newValue) |
90 | 1.86k | { |
91 | 1.86k | m_priv->threadInfo = newValue; |
92 | 1.86k | } |
93 | | |
94 | | bool JSONLayout::getThreadInfo() const |
95 | 0 | { |
96 | 0 | return m_priv->threadInfo; |
97 | 0 | } |
98 | | |
99 | | LogString JSONLayout::getContentType() const |
100 | 0 | { |
101 | 0 | return LOG4CXX_STR("application/json"); |
102 | 0 | } |
103 | | |
104 | | void JSONLayout::activateOptions(helpers::Pool& /* p */) |
105 | 0 | { |
106 | 0 | m_priv->expectedPatternLength = getFormattedEventCharacterCount() * 2; |
107 | 0 | } |
108 | | |
109 | | void JSONLayout::setOption(const LogString& option, const LogString& value) |
110 | 5.47k | { |
111 | 5.47k | if (StringHelper::equalsIgnoreCase(option, |
112 | 5.47k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) |
113 | 1.87k | { |
114 | 1.87k | setLocationInfo(OptionConverter::toBoolean(value, false)); |
115 | 1.87k | } |
116 | 3.60k | else if (StringHelper::equalsIgnoreCase(option, |
117 | 3.60k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) |
118 | 1.86k | { |
119 | 1.86k | setThreadInfo(OptionConverter::toBoolean(value, false)); |
120 | 1.86k | } |
121 | 1.74k | else if (StringHelper::equalsIgnoreCase(option, |
122 | 1.74k | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) |
123 | 1.74k | { |
124 | 1.74k | setPrettyPrint(OptionConverter::toBoolean(value, false)); |
125 | 1.74k | } |
126 | 5.47k | } 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 | 110 | 2.33k | { | 111 | 2.33k | if (StringHelper::equalsIgnoreCase(option, | 112 | 2.33k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) | 113 | 813 | { | 114 | 813 | setLocationInfo(OptionConverter::toBoolean(value, false)); | 115 | 813 | } | 116 | 1.52k | else if (StringHelper::equalsIgnoreCase(option, | 117 | 1.52k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) | 118 | 791 | { | 119 | 791 | setThreadInfo(OptionConverter::toBoolean(value, false)); | 120 | 791 | } | 121 | 730 | else if (StringHelper::equalsIgnoreCase(option, | 122 | 730 | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) | 123 | 730 | { | 124 | 730 | setPrettyPrint(OptionConverter::toBoolean(value, false)); | 125 | 730 | } | 126 | 2.33k | } |
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 | 110 | 3.14k | { | 111 | 3.14k | if (StringHelper::equalsIgnoreCase(option, | 112 | 3.14k | LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) | 113 | 1.05k | { | 114 | 1.05k | setLocationInfo(OptionConverter::toBoolean(value, false)); | 115 | 1.05k | } | 116 | 2.08k | else if (StringHelper::equalsIgnoreCase(option, | 117 | 2.08k | LOG4CXX_STR("THREADINFO"), LOG4CXX_STR("threadinfo"))) | 118 | 1.06k | { | 119 | 1.06k | setThreadInfo(OptionConverter::toBoolean(value, false)); | 120 | 1.06k | } | 121 | 1.01k | else if (StringHelper::equalsIgnoreCase(option, | 122 | 1.01k | LOG4CXX_STR("PRETTYPRINT"), LOG4CXX_STR("prettyprint"))) | 123 | 1.01k | { | 124 | 1.01k | setPrettyPrint(OptionConverter::toBoolean(value, false)); | 125 | 1.01k | } | 126 | 3.14k | } |
|
127 | | |
128 | | void JSONLayout::format(LogString& output, |
129 | | const spi::LoggingEventPtr& event, |
130 | | Pool& p) const |
131 | 2.88k | { |
132 | 2.88k | output.reserve(m_priv->expectedPatternLength + event->getMessage().size()); |
133 | 2.88k | output.append(LOG4CXX_STR("{")); |
134 | 2.88k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
135 | | |
136 | 2.88k | if (m_priv->prettyPrint) |
137 | 1.74k | { |
138 | 1.74k | output.append(m_priv->ppIndentL1); |
139 | 1.74k | } |
140 | | |
141 | 2.88k | appendQuotedEscapedString(output, LOG4CXX_STR("timestamp")); |
142 | 2.88k | output.append(LOG4CXX_STR(": ")); |
143 | 2.88k | LogString timestamp; |
144 | 2.88k | m_priv->dateFormat.format(timestamp, event->getTimeStamp(), p); |
145 | 2.88k | appendQuotedEscapedString(output, timestamp); |
146 | 2.88k | output.append(LOG4CXX_STR(",")); |
147 | 2.88k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
148 | | |
149 | 2.88k | if (m_priv->threadInfo) |
150 | 1.86k | { |
151 | 1.86k | if (m_priv->prettyPrint) |
152 | 1.40k | { |
153 | 1.40k | output.append(m_priv->ppIndentL1); |
154 | 1.40k | } |
155 | 1.86k | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); |
156 | 1.86k | output.append(LOG4CXX_STR(": ")); |
157 | 1.86k | appendQuotedEscapedString(output, event->getThreadName()); |
158 | 1.86k | output.append(LOG4CXX_STR(",")); |
159 | 1.86k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
160 | 1.86k | } |
161 | | |
162 | 2.88k | if (m_priv->prettyPrint) |
163 | 1.74k | { |
164 | 1.74k | output.append(m_priv->ppIndentL1); |
165 | 1.74k | } |
166 | | |
167 | 2.88k | appendQuotedEscapedString(output, LOG4CXX_STR("level")); |
168 | 2.88k | output.append(LOG4CXX_STR(": ")); |
169 | 2.88k | LogString level; |
170 | 2.88k | event->getLevel()->toString(level); |
171 | 2.88k | appendQuotedEscapedString(output, level); |
172 | 2.88k | output.append(LOG4CXX_STR(",")); |
173 | 2.88k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
174 | | |
175 | 2.88k | if (m_priv->prettyPrint) |
176 | 1.74k | { |
177 | 1.74k | output.append(m_priv->ppIndentL1); |
178 | 1.74k | } |
179 | | |
180 | 2.88k | appendQuotedEscapedString(output, LOG4CXX_STR("logger")); |
181 | 2.88k | output.append(LOG4CXX_STR(": ")); |
182 | 2.88k | appendQuotedEscapedString(output, event->getLoggerName()); |
183 | 2.88k | output.append(LOG4CXX_STR(",")); |
184 | 2.88k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
185 | | |
186 | 2.88k | if (m_priv->prettyPrint) |
187 | 1.74k | { |
188 | 1.74k | output.append(m_priv->ppIndentL1); |
189 | 1.74k | } |
190 | | |
191 | 2.88k | appendQuotedEscapedString(output, LOG4CXX_STR("message")); |
192 | 2.88k | output.append(LOG4CXX_STR(": ")); |
193 | 2.88k | appendQuotedEscapedString(output, event->getMessage()); |
194 | | |
195 | 2.88k | appendSerializedMDC(output, event); |
196 | 2.88k | appendSerializedNDC(output, event); |
197 | | |
198 | 2.88k | if (m_priv->locationInfo) |
199 | 1.87k | { |
200 | 1.87k | output.append(LOG4CXX_STR(",")); |
201 | 1.87k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
202 | 1.87k | appendSerializedLocationInfo(output, event, p); |
203 | 1.87k | } |
204 | | |
205 | 2.88k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
206 | 2.88k | output.append(LOG4CXX_STR("}")); |
207 | 2.88k | output.append(LOG4CXX_EOL); |
208 | 2.88k | } 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 | 131 | 1.24k | { | 132 | 1.24k | output.reserve(m_priv->expectedPatternLength + event->getMessage().size()); | 133 | 1.24k | output.append(LOG4CXX_STR("{")); | 134 | 1.24k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 135 | | | 136 | 1.24k | if (m_priv->prettyPrint) | 137 | 730 | { | 138 | 730 | output.append(m_priv->ppIndentL1); | 139 | 730 | } | 140 | | | 141 | 1.24k | appendQuotedEscapedString(output, LOG4CXX_STR("timestamp")); | 142 | 1.24k | output.append(LOG4CXX_STR(": ")); | 143 | 1.24k | LogString timestamp; | 144 | 1.24k | m_priv->dateFormat.format(timestamp, event->getTimeStamp(), p); | 145 | 1.24k | appendQuotedEscapedString(output, timestamp); | 146 | 1.24k | output.append(LOG4CXX_STR(",")); | 147 | 1.24k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 148 | | | 149 | 1.24k | if (m_priv->threadInfo) | 150 | 791 | { | 151 | 791 | if (m_priv->prettyPrint) | 152 | 592 | { | 153 | 592 | output.append(m_priv->ppIndentL1); | 154 | 592 | } | 155 | 791 | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); | 156 | 791 | output.append(LOG4CXX_STR(": ")); | 157 | 791 | appendQuotedEscapedString(output, event->getThreadName()); | 158 | 791 | output.append(LOG4CXX_STR(",")); | 159 | 791 | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 160 | 791 | } | 161 | | | 162 | 1.24k | if (m_priv->prettyPrint) | 163 | 730 | { | 164 | 730 | output.append(m_priv->ppIndentL1); | 165 | 730 | } | 166 | | | 167 | 1.24k | appendQuotedEscapedString(output, LOG4CXX_STR("level")); | 168 | 1.24k | output.append(LOG4CXX_STR(": ")); | 169 | 1.24k | LogString level; | 170 | 1.24k | event->getLevel()->toString(level); | 171 | 1.24k | appendQuotedEscapedString(output, level); | 172 | 1.24k | output.append(LOG4CXX_STR(",")); | 173 | 1.24k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 174 | | | 175 | 1.24k | if (m_priv->prettyPrint) | 176 | 730 | { | 177 | 730 | output.append(m_priv->ppIndentL1); | 178 | 730 | } | 179 | | | 180 | 1.24k | appendQuotedEscapedString(output, LOG4CXX_STR("logger")); | 181 | 1.24k | output.append(LOG4CXX_STR(": ")); | 182 | 1.24k | appendQuotedEscapedString(output, event->getLoggerName()); | 183 | 1.24k | output.append(LOG4CXX_STR(",")); | 184 | 1.24k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 185 | | | 186 | 1.24k | if (m_priv->prettyPrint) | 187 | 730 | { | 188 | 730 | output.append(m_priv->ppIndentL1); | 189 | 730 | } | 190 | | | 191 | 1.24k | appendQuotedEscapedString(output, LOG4CXX_STR("message")); | 192 | 1.24k | output.append(LOG4CXX_STR(": ")); | 193 | 1.24k | appendQuotedEscapedString(output, event->getMessage()); | 194 | | | 195 | 1.24k | appendSerializedMDC(output, event); | 196 | 1.24k | appendSerializedNDC(output, event); | 197 | | | 198 | 1.24k | if (m_priv->locationInfo) | 199 | 813 | { | 200 | 813 | output.append(LOG4CXX_STR(",")); | 201 | 813 | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 202 | 813 | appendSerializedLocationInfo(output, event, p); | 203 | 813 | } | 204 | | | 205 | 1.24k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 206 | 1.24k | output.append(LOG4CXX_STR("}")); | 207 | 1.24k | output.append(LOG4CXX_EOL); | 208 | 1.24k | } |
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 | 131 | 1.63k | { | 132 | 1.63k | output.reserve(m_priv->expectedPatternLength + event->getMessage().size()); | 133 | 1.63k | output.append(LOG4CXX_STR("{")); | 134 | 1.63k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 135 | | | 136 | 1.63k | if (m_priv->prettyPrint) | 137 | 1.01k | { | 138 | 1.01k | output.append(m_priv->ppIndentL1); | 139 | 1.01k | } | 140 | | | 141 | 1.63k | appendQuotedEscapedString(output, LOG4CXX_STR("timestamp")); | 142 | 1.63k | output.append(LOG4CXX_STR(": ")); | 143 | 1.63k | LogString timestamp; | 144 | 1.63k | m_priv->dateFormat.format(timestamp, event->getTimeStamp(), p); | 145 | 1.63k | appendQuotedEscapedString(output, timestamp); | 146 | 1.63k | output.append(LOG4CXX_STR(",")); | 147 | 1.63k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 148 | | | 149 | 1.63k | if (m_priv->threadInfo) | 150 | 1.06k | { | 151 | 1.06k | if (m_priv->prettyPrint) | 152 | 816 | { | 153 | 816 | output.append(m_priv->ppIndentL1); | 154 | 816 | } | 155 | 1.06k | appendQuotedEscapedString(output, LOG4CXX_STR("thread")); | 156 | 1.06k | output.append(LOG4CXX_STR(": ")); | 157 | 1.06k | appendQuotedEscapedString(output, event->getThreadName()); | 158 | 1.06k | output.append(LOG4CXX_STR(",")); | 159 | 1.06k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 160 | 1.06k | } | 161 | | | 162 | 1.63k | if (m_priv->prettyPrint) | 163 | 1.01k | { | 164 | 1.01k | output.append(m_priv->ppIndentL1); | 165 | 1.01k | } | 166 | | | 167 | 1.63k | appendQuotedEscapedString(output, LOG4CXX_STR("level")); | 168 | 1.63k | output.append(LOG4CXX_STR(": ")); | 169 | 1.63k | LogString level; | 170 | 1.63k | event->getLevel()->toString(level); | 171 | 1.63k | appendQuotedEscapedString(output, level); | 172 | 1.63k | output.append(LOG4CXX_STR(",")); | 173 | 1.63k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 174 | | | 175 | 1.63k | if (m_priv->prettyPrint) | 176 | 1.01k | { | 177 | 1.01k | output.append(m_priv->ppIndentL1); | 178 | 1.01k | } | 179 | | | 180 | 1.63k | appendQuotedEscapedString(output, LOG4CXX_STR("logger")); | 181 | 1.63k | output.append(LOG4CXX_STR(": ")); | 182 | 1.63k | appendQuotedEscapedString(output, event->getLoggerName()); | 183 | 1.63k | output.append(LOG4CXX_STR(",")); | 184 | 1.63k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 185 | | | 186 | 1.63k | if (m_priv->prettyPrint) | 187 | 1.01k | { | 188 | 1.01k | output.append(m_priv->ppIndentL1); | 189 | 1.01k | } | 190 | | | 191 | 1.63k | appendQuotedEscapedString(output, LOG4CXX_STR("message")); | 192 | 1.63k | output.append(LOG4CXX_STR(": ")); | 193 | 1.63k | appendQuotedEscapedString(output, event->getMessage()); | 194 | | | 195 | 1.63k | appendSerializedMDC(output, event); | 196 | 1.63k | appendSerializedNDC(output, event); | 197 | | | 198 | 1.63k | if (m_priv->locationInfo) | 199 | 1.05k | { | 200 | 1.05k | output.append(LOG4CXX_STR(",")); | 201 | 1.05k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 202 | 1.05k | appendSerializedLocationInfo(output, event, p); | 203 | 1.05k | } | 204 | | | 205 | 1.63k | output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 206 | 1.63k | output.append(LOG4CXX_STR("}")); | 207 | 1.63k | output.append(LOG4CXX_EOL); | 208 | 1.63k | } |
|
209 | | |
210 | | void JSONLayout::appendQuotedEscapedString(LogString& buf, |
211 | | const LogString& input) const |
212 | 60.9k | { |
213 | 60.9k | appendItem(input, buf); |
214 | 60.9k | } 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 | 212 | 26.3k | { | 213 | 26.3k | appendItem(input, buf); | 214 | 26.3k | } |
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 | 212 | 34.6k | { | 213 | 34.6k | appendItem(input, buf); | 214 | 34.6k | } |
|
215 | | |
216 | | void JSONLayout::appendItem(const LogString& input, LogString& buf) |
217 | 60.9k | { |
218 | | /* add leading quote */ |
219 | 60.9k | buf.push_back(0x22); |
220 | | |
221 | 60.9k | logchar specialChars[] = |
222 | 60.9k | { |
223 | 60.9k | 0x08, /* \b backspace */ |
224 | 60.9k | 0x09, /* \t tab */ |
225 | 60.9k | 0x0a, /* \n newline */ |
226 | 60.9k | 0x0c, /* \f form feed */ |
227 | 60.9k | 0x0d, /* \r carriage return */ |
228 | 60.9k | 0x22, /* \" double quote */ |
229 | 60.9k | 0x5c, /* \\ backslash */ |
230 | 60.9k | 0x00 /* terminating NULL for C-strings */ |
231 | 60.9k | }; |
232 | | |
233 | 60.9k | size_t start = 0; |
234 | 60.9k | size_t found = input.find_first_of(specialChars, start); |
235 | | |
236 | 746k | while (found != LogString::npos) |
237 | 685k | { |
238 | 685k | if (found > start) |
239 | 13.5k | { |
240 | 13.5k | buf.append(input, start, found - start); |
241 | 13.5k | } |
242 | | |
243 | 685k | switch (input[found]) |
244 | 685k | { |
245 | 38.8k | case 0x08: |
246 | | /* \b backspace */ |
247 | 38.8k | buf.push_back(0x5c); |
248 | 38.8k | buf.push_back('b'); |
249 | 38.8k | break; |
250 | | |
251 | 140k | case 0x09: |
252 | | /* \t tab */ |
253 | 140k | buf.push_back(0x5c); |
254 | 140k | buf.push_back('t'); |
255 | 140k | break; |
256 | | |
257 | 283k | case 0x0a: |
258 | | /* \n newline */ |
259 | 283k | buf.push_back(0x5c); |
260 | 283k | buf.push_back('n'); |
261 | 283k | break; |
262 | | |
263 | 119k | case 0x0c: |
264 | | /* \f form feed */ |
265 | 119k | buf.push_back(0x5c); |
266 | 119k | buf.push_back('f'); |
267 | 119k | break; |
268 | | |
269 | 64.1k | case 0x0d: |
270 | | /* \r carriage return */ |
271 | 64.1k | buf.push_back(0x5c); |
272 | 64.1k | buf.push_back('r'); |
273 | 64.1k | break; |
274 | | |
275 | 38.7k | case 0x22: |
276 | | /* \" double quote */ |
277 | 38.7k | buf.push_back(0x5c); |
278 | 38.7k | buf.push_back(0x22); |
279 | 38.7k | break; |
280 | | |
281 | 991 | case 0x5c: |
282 | | /* \\ backslash */ |
283 | 991 | buf.push_back(0x5c); |
284 | 991 | buf.push_back(0x5c); |
285 | 991 | break; |
286 | | |
287 | 0 | default: |
288 | 0 | buf.push_back(input[found]); |
289 | 0 | break; |
290 | 685k | } |
291 | | |
292 | 685k | start = found + 1; |
293 | | |
294 | 685k | if (found < input.size()) |
295 | 685k | { |
296 | 685k | found = input.find_first_of(specialChars, start); |
297 | 685k | } |
298 | 0 | else |
299 | 0 | { |
300 | 0 | found = LogString::npos; |
301 | 0 | } |
302 | 685k | } |
303 | | |
304 | 60.9k | if (start < input.size()) |
305 | 43.9k | { |
306 | 43.9k | buf.append(input, start, input.size() - start); |
307 | 43.9k | } |
308 | | |
309 | | /* add trailing quote */ |
310 | 60.9k | buf.push_back(0x22); |
311 | 60.9k | } 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 | 217 | 26.3k | { | 218 | | /* add leading quote */ | 219 | 26.3k | buf.push_back(0x22); | 220 | | | 221 | 26.3k | logchar specialChars[] = | 222 | 26.3k | { | 223 | 26.3k | 0x08, /* \b backspace */ | 224 | 26.3k | 0x09, /* \t tab */ | 225 | 26.3k | 0x0a, /* \n newline */ | 226 | 26.3k | 0x0c, /* \f form feed */ | 227 | 26.3k | 0x0d, /* \r carriage return */ | 228 | 26.3k | 0x22, /* \" double quote */ | 229 | 26.3k | 0x5c, /* \\ backslash */ | 230 | 26.3k | 0x00 /* terminating NULL for C-strings */ | 231 | 26.3k | }; | 232 | | | 233 | 26.3k | size_t start = 0; | 234 | 26.3k | size_t found = input.find_first_of(specialChars, start); | 235 | | | 236 | 338k | while (found != LogString::npos) | 237 | 312k | { | 238 | 312k | if (found > start) | 239 | 7.76k | { | 240 | 7.76k | buf.append(input, start, found - start); | 241 | 7.76k | } | 242 | | | 243 | 312k | switch (input[found]) | 244 | 312k | { | 245 | 20.8k | case 0x08: | 246 | | /* \b backspace */ | 247 | 20.8k | buf.push_back(0x5c); | 248 | 20.8k | buf.push_back('b'); | 249 | 20.8k | break; | 250 | | | 251 | 10.9k | case 0x09: | 252 | | /* \t tab */ | 253 | 10.9k | buf.push_back(0x5c); | 254 | 10.9k | buf.push_back('t'); | 255 | 10.9k | break; | 256 | | | 257 | 267k | case 0x0a: | 258 | | /* \n newline */ | 259 | 267k | buf.push_back(0x5c); | 260 | 267k | buf.push_back('n'); | 261 | 267k | break; | 262 | | | 263 | 2.73k | case 0x0c: | 264 | | /* \f form feed */ | 265 | 2.73k | buf.push_back(0x5c); | 266 | 2.73k | buf.push_back('f'); | 267 | 2.73k | break; | 268 | | | 269 | 6.22k | case 0x0d: | 270 | | /* \r carriage return */ | 271 | 6.22k | buf.push_back(0x5c); | 272 | 6.22k | buf.push_back('r'); | 273 | 6.22k | break; | 274 | | | 275 | 3.52k | case 0x22: | 276 | | /* \" double quote */ | 277 | 3.52k | buf.push_back(0x5c); | 278 | 3.52k | buf.push_back(0x22); | 279 | 3.52k | break; | 280 | | | 281 | 450 | case 0x5c: | 282 | | /* \\ backslash */ | 283 | 450 | buf.push_back(0x5c); | 284 | 450 | buf.push_back(0x5c); | 285 | 450 | break; | 286 | | | 287 | 0 | default: | 288 | 0 | buf.push_back(input[found]); | 289 | 0 | break; | 290 | 312k | } | 291 | | | 292 | 312k | start = found + 1; | 293 | | | 294 | 312k | if (found < input.size()) | 295 | 312k | { | 296 | 312k | found = input.find_first_of(specialChars, start); | 297 | 312k | } | 298 | 0 | else | 299 | 0 | { | 300 | 0 | found = LogString::npos; | 301 | 0 | } | 302 | 312k | } | 303 | | | 304 | 26.3k | if (start < input.size()) | 305 | 19.0k | { | 306 | 19.0k | buf.append(input, start, input.size() - start); | 307 | 19.0k | } | 308 | | | 309 | | /* add trailing quote */ | 310 | 26.3k | buf.push_back(0x22); | 311 | 26.3k | } |
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 | 217 | 34.6k | { | 218 | | /* add leading quote */ | 219 | 34.6k | buf.push_back(0x22); | 220 | | | 221 | 34.6k | logchar specialChars[] = | 222 | 34.6k | { | 223 | 34.6k | 0x08, /* \b backspace */ | 224 | 34.6k | 0x09, /* \t tab */ | 225 | 34.6k | 0x0a, /* \n newline */ | 226 | 34.6k | 0x0c, /* \f form feed */ | 227 | 34.6k | 0x0d, /* \r carriage return */ | 228 | 34.6k | 0x22, /* \" double quote */ | 229 | 34.6k | 0x5c, /* \\ backslash */ | 230 | 34.6k | 0x00 /* terminating NULL for C-strings */ | 231 | 34.6k | }; | 232 | | | 233 | 34.6k | size_t start = 0; | 234 | 34.6k | size_t found = input.find_first_of(specialChars, start); | 235 | | | 236 | 408k | while (found != LogString::npos) | 237 | 373k | { | 238 | 373k | if (found > start) | 239 | 5.76k | { | 240 | 5.76k | buf.append(input, start, found - start); | 241 | 5.76k | } | 242 | | | 243 | 373k | switch (input[found]) | 244 | 373k | { | 245 | 18.0k | case 0x08: | 246 | | /* \b backspace */ | 247 | 18.0k | buf.push_back(0x5c); | 248 | 18.0k | buf.push_back('b'); | 249 | 18.0k | break; | 250 | | | 251 | 129k | case 0x09: | 252 | | /* \t tab */ | 253 | 129k | buf.push_back(0x5c); | 254 | 129k | buf.push_back('t'); | 255 | 129k | break; | 256 | | | 257 | 15.6k | case 0x0a: | 258 | | /* \n newline */ | 259 | 15.6k | buf.push_back(0x5c); | 260 | 15.6k | buf.push_back('n'); | 261 | 15.6k | break; | 262 | | | 263 | 116k | case 0x0c: | 264 | | /* \f form feed */ | 265 | 116k | buf.push_back(0x5c); | 266 | 116k | buf.push_back('f'); | 267 | 116k | break; | 268 | | | 269 | 57.9k | case 0x0d: | 270 | | /* \r carriage return */ | 271 | 57.9k | buf.push_back(0x5c); | 272 | 57.9k | buf.push_back('r'); | 273 | 57.9k | break; | 274 | | | 275 | 35.2k | case 0x22: | 276 | | /* \" double quote */ | 277 | 35.2k | buf.push_back(0x5c); | 278 | 35.2k | buf.push_back(0x22); | 279 | 35.2k | break; | 280 | | | 281 | 541 | case 0x5c: | 282 | | /* \\ backslash */ | 283 | 541 | buf.push_back(0x5c); | 284 | 541 | buf.push_back(0x5c); | 285 | 541 | break; | 286 | | | 287 | 0 | default: | 288 | 0 | buf.push_back(input[found]); | 289 | 0 | break; | 290 | 373k | } | 291 | | | 292 | 373k | start = found + 1; | 293 | | | 294 | 373k | if (found < input.size()) | 295 | 373k | { | 296 | 373k | found = input.find_first_of(specialChars, start); | 297 | 373k | } | 298 | 0 | else | 299 | 0 | { | 300 | 0 | found = LogString::npos; | 301 | 0 | } | 302 | 373k | } | 303 | | | 304 | 34.6k | if (start < input.size()) | 305 | 24.8k | { | 306 | 24.8k | buf.append(input, start, input.size() - start); | 307 | 24.8k | } | 308 | | | 309 | | /* add trailing quote */ | 310 | 34.6k | buf.push_back(0x22); | 311 | 34.6k | } |
|
312 | | |
313 | | void JSONLayout::appendSerializedMDC(LogString& buf, |
314 | | const LoggingEventPtr& event) const |
315 | 2.88k | { |
316 | 2.88k | LoggingEvent::KeySet keys = event->getMDCKeySet(); |
317 | | |
318 | 2.88k | if (keys.empty()) |
319 | 0 | { |
320 | 0 | return; |
321 | 0 | } |
322 | | |
323 | 2.88k | buf.append(LOG4CXX_STR(",")); |
324 | 2.88k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
325 | | |
326 | 2.88k | if (m_priv->prettyPrint) |
327 | 1.74k | { |
328 | 1.74k | buf.append(m_priv->ppIndentL1); |
329 | 1.74k | } |
330 | | |
331 | 2.88k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); |
332 | 2.88k | buf.append(LOG4CXX_STR(": {")); |
333 | 2.88k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
334 | | |
335 | 2.88k | for (LoggingEvent::KeySet::iterator it = keys.begin(); |
336 | 7.21k | it != keys.end(); ++it) |
337 | 4.32k | { |
338 | 4.32k | if (m_priv->prettyPrint) |
339 | 2.79k | { |
340 | 2.79k | buf.append(m_priv->ppIndentL2); |
341 | 2.79k | } |
342 | | |
343 | 4.32k | appendQuotedEscapedString(buf, *it); |
344 | 4.32k | buf.append(LOG4CXX_STR(": ")); |
345 | 4.32k | LogString value; |
346 | 4.32k | event->getMDC(*it, value); |
347 | 4.32k | appendQuotedEscapedString(buf, value); |
348 | | |
349 | | /* if this isn't the last k:v pair, we need a comma */ |
350 | 4.32k | if (it + 1 != keys.end()) |
351 | 1.44k | { |
352 | 1.44k | buf.append(LOG4CXX_STR(",")); |
353 | 1.44k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
354 | 1.44k | } |
355 | 2.88k | else |
356 | 2.88k | { |
357 | 2.88k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
358 | 2.88k | } |
359 | 4.32k | } |
360 | | |
361 | 2.88k | if (m_priv->prettyPrint) |
362 | 1.74k | { |
363 | 1.74k | buf.append(m_priv->ppIndentL1); |
364 | 1.74k | } |
365 | | |
366 | 2.88k | buf.append(LOG4CXX_STR("}")); |
367 | 2.88k | } 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 | 315 | 1.24k | { | 316 | 1.24k | LoggingEvent::KeySet keys = event->getMDCKeySet(); | 317 | | | 318 | 1.24k | if (keys.empty()) | 319 | 0 | { | 320 | 0 | return; | 321 | 0 | } | 322 | | | 323 | 1.24k | buf.append(LOG4CXX_STR(",")); | 324 | 1.24k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 325 | | | 326 | 1.24k | if (m_priv->prettyPrint) | 327 | 730 | { | 328 | 730 | buf.append(m_priv->ppIndentL1); | 329 | 730 | } | 330 | | | 331 | 1.24k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); | 332 | 1.24k | buf.append(LOG4CXX_STR(": {")); | 333 | 1.24k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 334 | | | 335 | 1.24k | for (LoggingEvent::KeySet::iterator it = keys.begin(); | 336 | 3.09k | it != keys.end(); ++it) | 337 | 1.85k | { | 338 | 1.85k | if (m_priv->prettyPrint) | 339 | 1.16k | { | 340 | 1.16k | buf.append(m_priv->ppIndentL2); | 341 | 1.16k | } | 342 | | | 343 | 1.85k | appendQuotedEscapedString(buf, *it); | 344 | 1.85k | buf.append(LOG4CXX_STR(": ")); | 345 | 1.85k | LogString value; | 346 | 1.85k | event->getMDC(*it, value); | 347 | 1.85k | appendQuotedEscapedString(buf, value); | 348 | | | 349 | | /* if this isn't the last k:v pair, we need a comma */ | 350 | 1.85k | if (it + 1 != keys.end()) | 351 | 603 | { | 352 | 603 | buf.append(LOG4CXX_STR(",")); | 353 | 603 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 354 | 603 | } | 355 | 1.24k | else | 356 | 1.24k | { | 357 | 1.24k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 358 | 1.24k | } | 359 | 1.85k | } | 360 | | | 361 | 1.24k | if (m_priv->prettyPrint) | 362 | 730 | { | 363 | 730 | buf.append(m_priv->ppIndentL1); | 364 | 730 | } | 365 | | | 366 | 1.24k | buf.append(LOG4CXX_STR("}")); | 367 | 1.24k | } |
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 | 315 | 1.63k | { | 316 | 1.63k | LoggingEvent::KeySet keys = event->getMDCKeySet(); | 317 | | | 318 | 1.63k | if (keys.empty()) | 319 | 0 | { | 320 | 0 | return; | 321 | 0 | } | 322 | | | 323 | 1.63k | buf.append(LOG4CXX_STR(",")); | 324 | 1.63k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 325 | | | 326 | 1.63k | if (m_priv->prettyPrint) | 327 | 1.01k | { | 328 | 1.01k | buf.append(m_priv->ppIndentL1); | 329 | 1.01k | } | 330 | | | 331 | 1.63k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_map")); | 332 | 1.63k | buf.append(LOG4CXX_STR(": {")); | 333 | 1.63k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 334 | | | 335 | 1.63k | for (LoggingEvent::KeySet::iterator it = keys.begin(); | 336 | 4.11k | it != keys.end(); ++it) | 337 | 2.47k | { | 338 | 2.47k | if (m_priv->prettyPrint) | 339 | 1.62k | { | 340 | 1.62k | buf.append(m_priv->ppIndentL2); | 341 | 1.62k | } | 342 | | | 343 | 2.47k | appendQuotedEscapedString(buf, *it); | 344 | 2.47k | buf.append(LOG4CXX_STR(": ")); | 345 | 2.47k | LogString value; | 346 | 2.47k | event->getMDC(*it, value); | 347 | 2.47k | appendQuotedEscapedString(buf, value); | 348 | | | 349 | | /* if this isn't the last k:v pair, we need a comma */ | 350 | 2.47k | if (it + 1 != keys.end()) | 351 | 842 | { | 352 | 842 | buf.append(LOG4CXX_STR(",")); | 353 | 842 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 354 | 842 | } | 355 | 1.63k | else | 356 | 1.63k | { | 357 | 1.63k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 358 | 1.63k | } | 359 | 2.47k | } | 360 | | | 361 | 1.63k | if (m_priv->prettyPrint) | 362 | 1.01k | { | 363 | 1.01k | buf.append(m_priv->ppIndentL1); | 364 | 1.01k | } | 365 | | | 366 | 1.63k | buf.append(LOG4CXX_STR("}")); | 367 | 1.63k | } |
|
368 | | |
369 | | void JSONLayout::appendSerializedNDC(LogString& buf, |
370 | | const LoggingEventPtr& event) const |
371 | 2.88k | { |
372 | 2.88k | LogString ndcVal; |
373 | | |
374 | 2.88k | if (!event->getNDC(ndcVal)) |
375 | 0 | { |
376 | 0 | return; |
377 | 0 | } |
378 | | |
379 | 2.88k | buf.append(LOG4CXX_STR(",")); |
380 | 2.88k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
381 | | |
382 | 2.88k | if (m_priv->prettyPrint) |
383 | 1.74k | { |
384 | 1.74k | buf.append(m_priv->ppIndentL1); |
385 | 1.74k | } |
386 | | |
387 | 2.88k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); |
388 | 2.88k | buf.append(LOG4CXX_STR(": [")); |
389 | 2.88k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
390 | | |
391 | 2.88k | if (m_priv->prettyPrint) |
392 | 1.74k | { |
393 | 1.74k | buf.append(m_priv->ppIndentL2); |
394 | 1.74k | } |
395 | | |
396 | 2.88k | appendQuotedEscapedString(buf, ndcVal); |
397 | 2.88k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
398 | | |
399 | 2.88k | if (m_priv->prettyPrint) |
400 | 1.74k | { |
401 | 1.74k | buf.append(m_priv->ppIndentL1); |
402 | 1.74k | } |
403 | | |
404 | 2.88k | buf.append(LOG4CXX_STR("]")); |
405 | 2.88k | } 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 | 371 | 1.24k | { | 372 | 1.24k | LogString ndcVal; | 373 | | | 374 | 1.24k | if (!event->getNDC(ndcVal)) | 375 | 0 | { | 376 | 0 | return; | 377 | 0 | } | 378 | | | 379 | 1.24k | buf.append(LOG4CXX_STR(",")); | 380 | 1.24k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 381 | | | 382 | 1.24k | if (m_priv->prettyPrint) | 383 | 730 | { | 384 | 730 | buf.append(m_priv->ppIndentL1); | 385 | 730 | } | 386 | | | 387 | 1.24k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); | 388 | 1.24k | buf.append(LOG4CXX_STR(": [")); | 389 | 1.24k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 390 | | | 391 | 1.24k | if (m_priv->prettyPrint) | 392 | 730 | { | 393 | 730 | buf.append(m_priv->ppIndentL2); | 394 | 730 | } | 395 | | | 396 | 1.24k | appendQuotedEscapedString(buf, ndcVal); | 397 | 1.24k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 398 | | | 399 | 1.24k | if (m_priv->prettyPrint) | 400 | 730 | { | 401 | 730 | buf.append(m_priv->ppIndentL1); | 402 | 730 | } | 403 | | | 404 | 1.24k | buf.append(LOG4CXX_STR("]")); | 405 | 1.24k | } |
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 | 371 | 1.63k | { | 372 | 1.63k | LogString ndcVal; | 373 | | | 374 | 1.63k | if (!event->getNDC(ndcVal)) | 375 | 0 | { | 376 | 0 | return; | 377 | 0 | } | 378 | | | 379 | 1.63k | buf.append(LOG4CXX_STR(",")); | 380 | 1.63k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 381 | | | 382 | 1.63k | if (m_priv->prettyPrint) | 383 | 1.01k | { | 384 | 1.01k | buf.append(m_priv->ppIndentL1); | 385 | 1.01k | } | 386 | | | 387 | 1.63k | appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack")); | 388 | 1.63k | buf.append(LOG4CXX_STR(": [")); | 389 | 1.63k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 390 | | | 391 | 1.63k | if (m_priv->prettyPrint) | 392 | 1.01k | { | 393 | 1.01k | buf.append(m_priv->ppIndentL2); | 394 | 1.01k | } | 395 | | | 396 | 1.63k | appendQuotedEscapedString(buf, ndcVal); | 397 | 1.63k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 398 | | | 399 | 1.63k | if (m_priv->prettyPrint) | 400 | 1.01k | { | 401 | 1.01k | buf.append(m_priv->ppIndentL1); | 402 | 1.01k | } | 403 | | | 404 | 1.63k | buf.append(LOG4CXX_STR("]")); | 405 | 1.63k | } |
|
406 | | |
407 | | void JSONLayout::appendSerializedLocationInfo(LogString& buf, |
408 | | const LoggingEventPtr& event, Pool& p) const |
409 | 1.87k | { |
410 | 1.87k | if (m_priv->prettyPrint) |
411 | 1.31k | { |
412 | 1.31k | buf.append(m_priv->ppIndentL1); |
413 | 1.31k | } |
414 | | |
415 | 1.87k | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); |
416 | 1.87k | buf.append(LOG4CXX_STR(": {")); |
417 | 1.87k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
418 | 1.87k | const LocationInfo& locInfo = event->getLocationInformation(); |
419 | | |
420 | 1.87k | if (m_priv->prettyPrint) |
421 | 1.31k | { |
422 | 1.31k | buf.append(m_priv->ppIndentL2); |
423 | 1.31k | } |
424 | | |
425 | 1.87k | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); |
426 | 1.87k | buf.append(LOG4CXX_STR(": ")); |
427 | 1.87k | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); |
428 | 1.87k | appendQuotedEscapedString(buf, fileName); |
429 | 1.87k | buf.append(LOG4CXX_STR(",")); |
430 | 1.87k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
431 | | |
432 | 1.87k | if (m_priv->prettyPrint) |
433 | 1.31k | { |
434 | 1.31k | buf.append(m_priv->ppIndentL2); |
435 | 1.31k | } |
436 | | |
437 | 1.87k | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); |
438 | 1.87k | buf.append(LOG4CXX_STR(": ")); |
439 | 1.87k | LogString lineNumber; |
440 | 1.87k | StringHelper::toString(locInfo.getLineNumber(), p, lineNumber); |
441 | 1.87k | appendQuotedEscapedString(buf, lineNumber); |
442 | 1.87k | buf.append(LOG4CXX_STR(",")); |
443 | 1.87k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
444 | | |
445 | 1.87k | if (m_priv->prettyPrint) |
446 | 1.31k | { |
447 | 1.31k | buf.append(m_priv->ppIndentL2); |
448 | 1.31k | } |
449 | | |
450 | 1.87k | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); |
451 | 1.87k | buf.append(LOG4CXX_STR(": ")); |
452 | 1.87k | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); |
453 | 1.87k | appendQuotedEscapedString(buf, className); |
454 | 1.87k | buf.append(LOG4CXX_STR(",")); |
455 | 1.87k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
456 | | |
457 | 1.87k | if (m_priv->prettyPrint) |
458 | 1.31k | { |
459 | 1.31k | buf.append(m_priv->ppIndentL2); |
460 | 1.31k | } |
461 | | |
462 | 1.87k | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); |
463 | 1.87k | buf.append(LOG4CXX_STR(": ")); |
464 | 1.87k | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); |
465 | 1.87k | appendQuotedEscapedString(buf, methodName); |
466 | 1.87k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); |
467 | | |
468 | 1.87k | if (m_priv->prettyPrint) |
469 | 1.31k | { |
470 | 1.31k | buf.append(m_priv->ppIndentL1); |
471 | 1.31k | } |
472 | | |
473 | 1.87k | buf.append(LOG4CXX_STR("}")); |
474 | 1.87k | } 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 | 409 | 813 | { | 410 | 813 | if (m_priv->prettyPrint) | 411 | 553 | { | 412 | 553 | buf.append(m_priv->ppIndentL1); | 413 | 553 | } | 414 | | | 415 | 813 | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); | 416 | 813 | buf.append(LOG4CXX_STR(": {")); | 417 | 813 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 418 | 813 | const LocationInfo& locInfo = event->getLocationInformation(); | 419 | | | 420 | 813 | if (m_priv->prettyPrint) | 421 | 553 | { | 422 | 553 | buf.append(m_priv->ppIndentL2); | 423 | 553 | } | 424 | | | 425 | 813 | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); | 426 | 813 | buf.append(LOG4CXX_STR(": ")); | 427 | 813 | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); | 428 | 813 | appendQuotedEscapedString(buf, fileName); | 429 | 813 | buf.append(LOG4CXX_STR(",")); | 430 | 813 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 431 | | | 432 | 813 | if (m_priv->prettyPrint) | 433 | 553 | { | 434 | 553 | buf.append(m_priv->ppIndentL2); | 435 | 553 | } | 436 | | | 437 | 813 | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); | 438 | 813 | buf.append(LOG4CXX_STR(": ")); | 439 | 813 | LogString lineNumber; | 440 | 813 | StringHelper::toString(locInfo.getLineNumber(), p, lineNumber); | 441 | 813 | appendQuotedEscapedString(buf, lineNumber); | 442 | 813 | buf.append(LOG4CXX_STR(",")); | 443 | 813 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 444 | | | 445 | 813 | if (m_priv->prettyPrint) | 446 | 553 | { | 447 | 553 | buf.append(m_priv->ppIndentL2); | 448 | 553 | } | 449 | | | 450 | 813 | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); | 451 | 813 | buf.append(LOG4CXX_STR(": ")); | 452 | 813 | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); | 453 | 813 | appendQuotedEscapedString(buf, className); | 454 | 813 | buf.append(LOG4CXX_STR(",")); | 455 | 813 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 456 | | | 457 | 813 | if (m_priv->prettyPrint) | 458 | 553 | { | 459 | 553 | buf.append(m_priv->ppIndentL2); | 460 | 553 | } | 461 | | | 462 | 813 | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); | 463 | 813 | buf.append(LOG4CXX_STR(": ")); | 464 | 813 | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); | 465 | 813 | appendQuotedEscapedString(buf, methodName); | 466 | 813 | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 467 | | | 468 | 813 | if (m_priv->prettyPrint) | 469 | 553 | { | 470 | 553 | buf.append(m_priv->ppIndentL1); | 471 | 553 | } | 472 | | | 473 | 813 | buf.append(LOG4CXX_STR("}")); | 474 | 813 | } |
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 | 409 | 1.05k | { | 410 | 1.05k | if (m_priv->prettyPrint) | 411 | 762 | { | 412 | 762 | buf.append(m_priv->ppIndentL1); | 413 | 762 | } | 414 | | | 415 | 1.05k | appendQuotedEscapedString(buf, LOG4CXX_STR("location_info")); | 416 | 1.05k | buf.append(LOG4CXX_STR(": {")); | 417 | 1.05k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 418 | 1.05k | const LocationInfo& locInfo = event->getLocationInformation(); | 419 | | | 420 | 1.05k | if (m_priv->prettyPrint) | 421 | 762 | { | 422 | 762 | buf.append(m_priv->ppIndentL2); | 423 | 762 | } | 424 | | | 425 | 1.05k | appendQuotedEscapedString(buf, LOG4CXX_STR("file")); | 426 | 1.05k | buf.append(LOG4CXX_STR(": ")); | 427 | 1.05k | LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); | 428 | 1.05k | appendQuotedEscapedString(buf, fileName); | 429 | 1.05k | buf.append(LOG4CXX_STR(",")); | 430 | 1.05k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 431 | | | 432 | 1.05k | if (m_priv->prettyPrint) | 433 | 762 | { | 434 | 762 | buf.append(m_priv->ppIndentL2); | 435 | 762 | } | 436 | | | 437 | 1.05k | appendQuotedEscapedString(buf, LOG4CXX_STR("line")); | 438 | 1.05k | buf.append(LOG4CXX_STR(": ")); | 439 | 1.05k | LogString lineNumber; | 440 | 1.05k | StringHelper::toString(locInfo.getLineNumber(), p, lineNumber); | 441 | 1.05k | appendQuotedEscapedString(buf, lineNumber); | 442 | 1.05k | buf.append(LOG4CXX_STR(",")); | 443 | 1.05k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 444 | | | 445 | 1.05k | if (m_priv->prettyPrint) | 446 | 762 | { | 447 | 762 | buf.append(m_priv->ppIndentL2); | 448 | 762 | } | 449 | | | 450 | 1.05k | appendQuotedEscapedString(buf, LOG4CXX_STR("class")); | 451 | 1.05k | buf.append(LOG4CXX_STR(": ")); | 452 | 1.05k | LOG4CXX_DECODE_CHAR(className, locInfo.getClassName()); | 453 | 1.05k | appendQuotedEscapedString(buf, className); | 454 | 1.05k | buf.append(LOG4CXX_STR(",")); | 455 | 1.05k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 456 | | | 457 | 1.05k | if (m_priv->prettyPrint) | 458 | 762 | { | 459 | 762 | buf.append(m_priv->ppIndentL2); | 460 | 762 | } | 461 | | | 462 | 1.05k | appendQuotedEscapedString(buf, LOG4CXX_STR("method")); | 463 | 1.05k | buf.append(LOG4CXX_STR(": ")); | 464 | 1.05k | LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName()); | 465 | 1.05k | appendQuotedEscapedString(buf, methodName); | 466 | 1.05k | buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); | 467 | | | 468 | 1.05k | if (m_priv->prettyPrint) | 469 | 762 | { | 470 | 762 | buf.append(m_priv->ppIndentL1); | 471 | 762 | } | 472 | | | 473 | 1.05k | buf.append(LOG4CXX_STR("}")); | 474 | 1.05k | } |
|
475 | | |