/src/logging-log4cxx/src/main/include/log4cxx/pattern/loggingeventpatternconverter.h
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 | | #ifndef _LOG4CXX_PATTERN_LOGGING_EVENT_PATTERN_CONVERTER_H |
19 | | #define _LOG4CXX_PATTERN_LOGGING_EVENT_PATTERN_CONVERTER_H |
20 | | |
21 | | #include <log4cxx/pattern/patternconverter.h> |
22 | | #include <log4cxx/spi/loggingevent.h> |
23 | | |
24 | | namespace LOG4CXX_NS |
25 | | { |
26 | | |
27 | | namespace pattern |
28 | | { |
29 | | /** |
30 | | * LoggingEventPatternConverter is a base class for pattern converters |
31 | | * that can format information from instances of LoggingEvent. |
32 | | * |
33 | | * |
34 | | * |
35 | | * |
36 | | */ |
37 | | class LOG4CXX_EXPORT LoggingEventPatternConverter : public PatternConverter |
38 | | { |
39 | | protected: |
40 | | /** |
41 | | * Constructs an instance of LoggingEventPatternConverter. |
42 | | * @param name name of converter. |
43 | | * @param style CSS style for output. |
44 | | */ |
45 | | LoggingEventPatternConverter( |
46 | | const LogString& name, const LogString& style); |
47 | | |
48 | | LoggingEventPatternConverter(std::unique_ptr<PatternConverterPrivate> priv); |
49 | | |
50 | | public: |
51 | | DECLARE_LOG4CXX_PATTERN(LoggingEventPatternConverter) |
52 | 3.18k | BEGIN_LOG4CXX_CAST_MAP() |
53 | 3.18k | LOG4CXX_CAST_ENTRY(LoggingEventPatternConverter) |
54 | 1.76k | LOG4CXX_CAST_ENTRY_CHAIN(PatternConverter) |
55 | 1.76k | END_LOG4CXX_CAST_MAP() |
56 | | |
57 | | /** |
58 | | * Formats an event into a string buffer. |
59 | | * @param event event to format, may not be null. |
60 | | * @param toAppendTo string buffer to which the formatted event will be appended. May not be null. |
61 | | * @param p pool for memory allocations needing during format. |
62 | | */ |
63 | | virtual void format( |
64 | | const spi::LoggingEventPtr& event, |
65 | | LogString& toAppendTo, |
66 | | helpers::Pool& p) const = 0; |
67 | | |
68 | | void format(const helpers::ObjectPtr& obj, |
69 | | LogString& toAppendTo, |
70 | | helpers::Pool& p) const override; |
71 | | |
72 | | /** |
73 | | * Normally pattern converters are not meant to handle Exceptions although |
74 | | * few pattern converters might. |
75 | | * |
76 | | * By examining the return values for this method, the containing layout will |
77 | | * determine whether it handles throwables or not. |
78 | | |
79 | | * @return true if this PatternConverter handles throwables |
80 | | */ |
81 | | virtual bool handlesThrowable() const; |
82 | | }; |
83 | | |
84 | | LOG4CXX_PTR_DEF(LoggingEventPatternConverter); |
85 | | |
86 | | } |
87 | | } |
88 | | |
89 | | #endif |