/src/logging-log4cxx/src/main/cpp/throwableinformationpatternconverter.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/pattern/throwableinformationpatternconverter.h> |
20 | | #include <log4cxx/spi/loggingevent.h> |
21 | | #include <log4cxx/spi/location/locationinfo.h> |
22 | | #include <log4cxx/helpers/stringhelper.h> |
23 | | #include <log4cxx/private/patternconverter_priv.h> |
24 | | |
25 | | using namespace LOG4CXX_NS; |
26 | | using namespace LOG4CXX_NS::pattern; |
27 | | using namespace LOG4CXX_NS::spi; |
28 | | using namespace LOG4CXX_NS::helpers; |
29 | | |
30 | | struct ThrowableInformationPatternConverter::ThrowableInformationPatternConverterPrivate : |
31 | | public PatternConverterPrivate |
32 | | { |
33 | | ThrowableInformationPatternConverterPrivate( const LogString& name, const LogString& style, bool shortReport ) : |
34 | 0 | PatternConverterPrivate( name, style ), |
35 | 0 | shortReport(shortReport) {} |
36 | | |
37 | | /** |
38 | | * If "short", only first line of throwable report will be formatted. |
39 | | */ |
40 | | const bool shortReport; |
41 | | }; |
42 | | |
43 | | IMPLEMENT_LOG4CXX_OBJECT(ThrowableInformationPatternConverter) |
44 | | |
45 | | ThrowableInformationPatternConverter::ThrowableInformationPatternConverter(bool shortReport1) : |
46 | 0 | LoggingEventPatternConverter( |
47 | 0 | std::make_unique<ThrowableInformationPatternConverterPrivate>( |
48 | 0 | LOG4CXX_STR("Throwable"), |
49 | 0 | LOG4CXX_STR("throwable"), |
50 | 0 | shortReport1)) |
51 | 0 | { |
52 | 0 | } Unexecuted instantiation: log4cxx::pattern::ThrowableInformationPatternConverter::ThrowableInformationPatternConverter(bool) Unexecuted instantiation: log4cxx::pattern::ThrowableInformationPatternConverter::ThrowableInformationPatternConverter(bool) |
53 | | |
54 | | PatternConverterPtr ThrowableInformationPatternConverter::newInstance( |
55 | | const std::vector<LogString>& options) |
56 | 0 | { |
57 | 0 | if (options.size() > 0 && options[0].compare(LOG4CXX_STR("short")) == 0) |
58 | 0 | { |
59 | 0 | static WideLife<PatternConverterPtr> shortConverter = std::make_shared<ThrowableInformationPatternConverter>(true); |
60 | 0 | return shortConverter; |
61 | 0 | } |
62 | | |
63 | 0 | static WideLife<PatternConverterPtr> converter = std::make_shared<ThrowableInformationPatternConverter>(false); |
64 | 0 | return converter; |
65 | 0 | } |
66 | | |
67 | | void ThrowableInformationPatternConverter::format( |
68 | | const LoggingEventPtr& /* event */, |
69 | | LogString& /* toAppendTo */, |
70 | | Pool& /* p */) const |
71 | 0 | { |
72 | 0 | } |
73 | | |
74 | | /** |
75 | | * This converter obviously handles throwables. |
76 | | * @return true. |
77 | | */ |
78 | | bool ThrowableInformationPatternConverter::handlesThrowable() const |
79 | 0 | { |
80 | 0 | return true; |
81 | 0 | } |