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