/src/logging-log4cxx/src/main/cpp/propertiespatternconverter.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/pattern/propertiespatternconverter.h> |
20 | | #include <log4cxx/spi/loggingevent.h> |
21 | | #include <log4cxx/spi/location/locationinfo.h> |
22 | | #include <log4cxx/private/patternconverter_priv.h> |
23 | | |
24 | | #include <iterator> |
25 | | |
26 | | using namespace LOG4CXX_NS; |
27 | | using namespace LOG4CXX_NS::pattern; |
28 | | using namespace LOG4CXX_NS::spi; |
29 | | using namespace LOG4CXX_NS::helpers; |
30 | | |
31 | 1.55k | #define priv static_cast<PropertiesPatternConverterPrivate*>(m_priv.get()) |
32 | | |
33 | | struct PropertiesPatternConverter::PropertiesPatternConverterPrivate : public PatternConverterPrivate |
34 | | { |
35 | | PropertiesPatternConverterPrivate( const LogString& name, const LogString& style, const LogString& propertyName ) : |
36 | 3.48k | PatternConverterPrivate( name, style ), |
37 | 3.48k | option(propertyName) {}log4cxx::pattern::PropertiesPatternConverter::PropertiesPatternConverterPrivate::PropertiesPatternConverterPrivate(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&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 36 | 1.93k | PatternConverterPrivate( name, style ), | 37 | 1.93k | option(propertyName) {} |
log4cxx::pattern::PropertiesPatternConverter::PropertiesPatternConverterPrivate::PropertiesPatternConverterPrivate(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&, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) Line | Count | Source | 36 | 1.55k | PatternConverterPrivate( name, style ), | 37 | 1.55k | option(propertyName) {} |
|
38 | | |
39 | | /** |
40 | | * Name of property to output. |
41 | | */ |
42 | | const LogString option; |
43 | | }; |
44 | | |
45 | | IMPLEMENT_LOG4CXX_OBJECT(PropertiesPatternConverter) |
46 | | |
47 | | PropertiesPatternConverter::PropertiesPatternConverter(const LogString& name1, |
48 | | const LogString& propertyName) : |
49 | 3.48k | LoggingEventPatternConverter( |
50 | 3.48k | std::make_unique<PropertiesPatternConverterPrivate>(name1, LOG4CXX_STR("property"), propertyName)) |
51 | 3.48k | { |
52 | 3.48k | } Unexecuted instantiation: log4cxx::pattern::PropertiesPatternConverter::PropertiesPatternConverter(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&) log4cxx::pattern::PropertiesPatternConverter::PropertiesPatternConverter(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 | 49 | 1.93k | LoggingEventPatternConverter( | 50 | 1.93k | std::make_unique<PropertiesPatternConverterPrivate>(name1, LOG4CXX_STR("property"), propertyName)) | 51 | 1.93k | { | 52 | 1.93k | } |
Unexecuted instantiation: log4cxx::pattern::PropertiesPatternConverter::PropertiesPatternConverter(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&) log4cxx::pattern::PropertiesPatternConverter::PropertiesPatternConverter(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 | 49 | 1.55k | LoggingEventPatternConverter( | 50 | 1.55k | std::make_unique<PropertiesPatternConverterPrivate>(name1, LOG4CXX_STR("property"), propertyName)) | 51 | 1.55k | { | 52 | 1.55k | } |
|
53 | | |
54 | | PatternConverterPtr PropertiesPatternConverter::newInstance( |
55 | | const std::vector<LogString>& options) |
56 | 2.86k | { |
57 | 2.86k | if (options.size() == 0) |
58 | 605 | { |
59 | 605 | static WideLife<PatternConverterPtr> def = std::make_shared<PropertiesPatternConverter>( |
60 | 605 | LOG4CXX_STR("Properties"), LOG4CXX_STR("")); |
61 | 605 | return def; |
62 | 605 | } |
63 | | |
64 | 2.26k | LogString converterName(LOG4CXX_STR("Property{")); |
65 | 2.26k | converterName.append(options[0]); |
66 | 2.26k | converterName.append(LOG4CXX_STR("}")); |
67 | 2.26k | return std::make_shared<PropertiesPatternConverter>(converterName, options[0]); |
68 | 2.86k | } log4cxx::pattern::PropertiesPatternConverter::newInstance(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) Line | Count | Source | 56 | 1.81k | { | 57 | 1.81k | if (options.size() == 0) | 58 | 332 | { | 59 | 332 | static WideLife<PatternConverterPtr> def = std::make_shared<PropertiesPatternConverter>( | 60 | 332 | LOG4CXX_STR("Properties"), LOG4CXX_STR("")); | 61 | 332 | return def; | 62 | 332 | } | 63 | | | 64 | 1.48k | LogString converterName(LOG4CXX_STR("Property{")); | 65 | 1.48k | converterName.append(options[0]); | 66 | 1.48k | converterName.append(LOG4CXX_STR("}")); | 67 | 1.48k | return std::make_shared<PropertiesPatternConverter>(converterName, options[0]); | 68 | 1.81k | } |
log4cxx::pattern::PropertiesPatternConverter::newInstance(std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > > const&) Line | Count | Source | 56 | 1.04k | { | 57 | 1.04k | if (options.size() == 0) | 58 | 273 | { | 59 | 273 | static WideLife<PatternConverterPtr> def = std::make_shared<PropertiesPatternConverter>( | 60 | 273 | LOG4CXX_STR("Properties"), LOG4CXX_STR("")); | 61 | 273 | return def; | 62 | 273 | } | 63 | | | 64 | 776 | LogString converterName(LOG4CXX_STR("Property{")); | 65 | 776 | converterName.append(options[0]); | 66 | 776 | converterName.append(LOG4CXX_STR("}")); | 67 | 776 | return std::make_shared<PropertiesPatternConverter>(converterName, options[0]); | 68 | 1.04k | } |
|
69 | | |
70 | | void PropertiesPatternConverter::format( |
71 | | const LoggingEventPtr& event, |
72 | | LogString& toAppendTo, |
73 | | Pool& /* p */) const |
74 | 1.22k | { |
75 | 1.22k | if (priv->option.length() == 0) |
76 | 893 | { |
77 | 893 | toAppendTo.append(1, (logchar) 0x7B /* '{' */); |
78 | | |
79 | 893 | for (auto const& item : event->getMDCKeySet()) |
80 | 0 | { |
81 | 0 | toAppendTo.append(1, (logchar) 0x7B /* '{' */); |
82 | 0 | toAppendTo.append(item); |
83 | 0 | toAppendTo.append(1, (logchar) 0x2C /* ',' */); |
84 | 0 | event->getMDC(item, toAppendTo); |
85 | 0 | toAppendTo.append(1, (logchar) 0x7D /* '}' */); |
86 | 0 | } |
87 | | |
88 | 893 | toAppendTo.append(1, (logchar) 0x7D /* '}' */); |
89 | | |
90 | 893 | } |
91 | 332 | else |
92 | 332 | { |
93 | 332 | event->getMDC(priv->option, toAppendTo); |
94 | 332 | } |
95 | 1.22k | } log4cxx::pattern::PropertiesPatternConverter::format(std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, log4cxx::helpers::Pool&) const Line | Count | Source | 74 | 445 | { | 75 | 445 | if (priv->option.length() == 0) | 76 | 289 | { | 77 | 289 | toAppendTo.append(1, (logchar) 0x7B /* '{' */); | 78 | | | 79 | 289 | for (auto const& item : event->getMDCKeySet()) | 80 | 0 | { | 81 | 0 | toAppendTo.append(1, (logchar) 0x7B /* '{' */); | 82 | 0 | toAppendTo.append(item); | 83 | 0 | toAppendTo.append(1, (logchar) 0x2C /* ',' */); | 84 | 0 | event->getMDC(item, toAppendTo); | 85 | 0 | toAppendTo.append(1, (logchar) 0x7D /* '}' */); | 86 | 0 | } | 87 | | | 88 | 289 | toAppendTo.append(1, (logchar) 0x7D /* '}' */); | 89 | | | 90 | 289 | } | 91 | 156 | else | 92 | 156 | { | 93 | 156 | event->getMDC(priv->option, toAppendTo); | 94 | 156 | } | 95 | 445 | } |
log4cxx::pattern::PropertiesPatternConverter::format(std::__1::shared_ptr<log4cxx::spi::LoggingEvent> const&, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&, log4cxx::helpers::Pool&) const Line | Count | Source | 74 | 780 | { | 75 | 780 | if (priv->option.length() == 0) | 76 | 604 | { | 77 | 604 | toAppendTo.append(1, (logchar) 0x7B /* '{' */); | 78 | | | 79 | 604 | for (auto const& item : event->getMDCKeySet()) | 80 | 0 | { | 81 | 0 | toAppendTo.append(1, (logchar) 0x7B /* '{' */); | 82 | 0 | toAppendTo.append(item); | 83 | 0 | toAppendTo.append(1, (logchar) 0x2C /* ',' */); | 84 | 0 | event->getMDC(item, toAppendTo); | 85 | 0 | toAppendTo.append(1, (logchar) 0x7D /* '}' */); | 86 | 0 | } | 87 | | | 88 | 604 | toAppendTo.append(1, (logchar) 0x7D /* '}' */); | 89 | | | 90 | 604 | } | 91 | 176 | else | 92 | 176 | { | 93 | 176 | event->getMDC(priv->option, toAppendTo); | 94 | 176 | } | 95 | 780 | } |
|
96 | | |