[2] | 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 | #ifndef _LOG4CXX_PATTERN_THROWABLE_INFORMATION_PATTERN_CONVERTER
|
---|
| 19 | #define _LOG4CXX_PATTERN_THROWABLE_INFORMATION_PATTERN_CONVERTER
|
---|
| 20 |
|
---|
| 21 | #include <log4cxx/pattern/loggingeventpatternconverter.h>
|
---|
| 22 |
|
---|
| 23 | namespace log4cxx { namespace pattern {
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | /**
|
---|
| 27 | * Outputs the ThrowableInformation portion of the LoggingiEvent as a full stacktrace
|
---|
| 28 | * unless this converter's option is 'short', where it just outputs the first line of the trace.
|
---|
| 29 | *
|
---|
| 30 | *
|
---|
| 31 | *
|
---|
| 32 | *
|
---|
| 33 | */
|
---|
| 34 | class LOG4CXX_EXPORT ThrowableInformationPatternConverter
|
---|
| 35 | : public LoggingEventPatternConverter {
|
---|
| 36 | /**
|
---|
| 37 | * If "short", only first line of throwable report will be formatted.
|
---|
| 38 | */
|
---|
| 39 | const bool shortReport;
|
---|
| 40 |
|
---|
| 41 | /**
|
---|
| 42 | * Private constructor.
|
---|
| 43 | */
|
---|
| 44 | ThrowableInformationPatternConverter(bool shortReport);
|
---|
| 45 |
|
---|
| 46 | public:
|
---|
| 47 | DECLARE_LOG4CXX_PATTERN(ThrowableInformationPatternConverter)
|
---|
| 48 | BEGIN_LOG4CXX_CAST_MAP()
|
---|
| 49 | LOG4CXX_CAST_ENTRY(ThrowableInformationPatternConverter)
|
---|
| 50 | LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
|
---|
| 51 | END_LOG4CXX_CAST_MAP()
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | /**
|
---|
| 55 | * Gets an instance of the class.
|
---|
| 56 | * @param options pattern options, may be null. If first element is "short",
|
---|
| 57 | * only the first line of the throwable will be formatted.
|
---|
| 58 | * @return instance of class.
|
---|
| 59 | */
|
---|
| 60 | static PatternConverterPtr newInstance(
|
---|
| 61 | const std::vector<LogString>& options);
|
---|
| 62 | void format(const log4cxx::spi::LoggingEventPtr& event,
|
---|
| 63 | LogString& toAppendTo,
|
---|
| 64 | log4cxx::helpers::Pool& p) const;
|
---|
| 65 |
|
---|
| 66 | /**
|
---|
| 67 | * This converter obviously handles throwables.
|
---|
| 68 | * @return true.
|
---|
| 69 | */
|
---|
| 70 | bool handlesThrowable() const;
|
---|
| 71 | };
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 | #endif
|
---|