Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
errorhandler.h
Go to the documentation of this file.
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_SPI_ERROR_HANDLER_H
19#define _LOG4CXX_SPI_ERROR_HANDLER_H
20
25
26namespace LOG4CXX_NS
27{
28namespace spi
29{
39
40
53class LOG4CXX_EXPORT ErrorHandler
54 : public OptionHandler
55{
56 public:
62
63 virtual ~ErrorHandler() {}
64
70 virtual void addAppenderHolder(const LogString& name, const AppenderAttachablePtr& clx);
71
79 virtual void setLogger(const LoggerPtr& logger);
80
88 virtual void error
89 ( const LogString& context
90 , const std::exception& e
92 ) = 0;
93
99 virtual void error(const LogString& message, ErrorCode category = ErrorCode::INVALID_CONFIGURATION) = 0;
100
111 virtual void error
112 ( const LogString& context
113 , const std::exception& e
114 , ErrorCode category
115 , const LoggingEventPtr& event
116 );
117
123 virtual void setAppender(const AppenderPtr& appender);
124
130 virtual void setBackupAppender(const AppenderPtr& appender);
131
137 virtual bool errorReported() const;
138
145 void activateOptions( ) override;
146};
147
149} //namespace spi
150} //namespace log4cxx
151
152#endif //_LOG4CXX_SPI_ERROR_HANDLER_H
Appenders may delegate their error handling to ErrorHandlers.
Definition errorhandler.h:55
virtual void error(const LogString &context, const std::exception &e, ErrorCode category=ErrorCode::GENERIC_FAILURE)=0
This method is invoked when an exception is thown.
virtual void setAppender(const AppenderPtr &appender)
Override this to set the appender holding this error handler.
virtual void error(const LogString &context, const std::exception &e, ErrorCode category, const LoggingEventPtr &event)
This method is invoked when an exception is thown while processing a spi::LoggingEvent.
virtual void addAppenderHolder(const LogString &name, const AppenderAttachablePtr &clx)
Override this to add clx to the list of collections to search for the failed appender.
virtual void setBackupAppender(const AppenderPtr &appender)
Override this to set the appender to fallback upon in case of failure.
virtual bool errorReported() const
Override this to report whether an error been raised to this reporter.
virtual void error(const LogString &message, ErrorCode category=ErrorCode::INVALID_CONFIGURATION)=0
This method is invoked when an error is detected but an exception is not available (e....
virtual void setLogger(const LoggerPtr &logger)
Override this to add a reference to a logger to which the failing appender might be attached.
void activateOptions() override
Activate the options that were previously set with calls to option setters.
A string based interface to configure package components.
Definition optionhandler.h:37
virtual void activateOptions()=0
Activate the options that were previously set with calls to option setters.
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition appender.h:32
LOG4CXX_PTR_DEF(LoggingEvent)
ErrorCode
Definition errorhandler.h:31
@ INVALID_CONFIGURATION
Definition errorhandler.h:37
@ GENERIC_FAILURE
Definition errorhandler.h:31
@ ROLLOVER_FAILURE
Definition errorhandler.h:36
@ CLOSE_FAILURE
Definition errorhandler.h:34
@ FLUSH_FAILURE
Definition errorhandler.h:33
@ WRITE_FAILURE
Definition errorhandler.h:32
@ OPEN_FAILURE
Definition errorhandler.h:35
std::basic_string< logchar > LogString
Definition logstring.h:51
std::shared_ptr< Appender > AppenderPtr
Definition basicconfigurator.h:29
std::shared_ptr< Logger > LoggerPtr
Definition provisionnode.h:28
#define LOG4CXX_CAST_ENTRY(Interface)
Definition object.h:153
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition object.h:37
#define END_LOG4CXX_CAST_MAP()
Definition object.h:147
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:141