source: pacpusframework/branches/0.1.x/3rd/apache-log4cxx/include/log4cxx/spi/errorhandler.h

Last change on this file was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 5.0 KB
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#ifndef _LOG4CXX_SPI_ERROR_HANDLER_H
19#define _LOG4CXX_SPI_ERROR_HANDLER_H
20
21#if defined(_MSC_VER)
22#pragma warning ( push )
23#pragma warning ( disable: 4231 4251 4275 4786 )
24#endif
25
26
27#include <log4cxx/spi/optionhandler.h>
28#include <log4cxx/helpers/exception.h>
29#include <log4cxx/appender.h>
30#include <log4cxx/spi/loggingevent.h>
31
32namespace log4cxx
33{
34 namespace spi
35 {
36 class ErrorCode
37 {
38 public:
39 enum
40 {
41 GENERIC_FAILURE = 0,
42 WRITE_FAILURE = 1,
43 FLUSH_FAILURE = 2,
44 CLOSE_FAILURE = 3,
45 FILE_OPEN_FAILURE = 4,
46 MISSING_LAYOUT = 5,
47 ADDRESS_PARSE_FAILURE = 6
48 };
49 };
50
51
52 /**
53 Appenders may delegate their error handling to
54 <code>ErrorHandlers</code>.
55
56 <p>Error handling is a particularly tedious to get right because by
57 definition errors are hard to predict and to reproduce.
58
59
60 <p>Please take the time to contact the author in case you discover
61 that errors are not properly handled. You are most welcome to
62 suggest new error handling policies or criticize existing policies.
63 */
64 class LOG4CXX_EXPORT ErrorHandler : public virtual OptionHandler
65 {
66 public:
67 DECLARE_ABSTRACT_LOG4CXX_OBJECT(ErrorHandler)
68 virtual ~ErrorHandler() {}
69
70 /**
71 Add a reference to a logger to which the failing appender might
72 be attached to. The failing appender will be searched and
73 replaced only in the loggers you add through this method.
74
75 @param logger One of the loggers that will be searched for the failing
76 appender in view of replacement.
77 */
78 virtual void setLogger(const LoggerPtr& logger) = 0;
79
80
81 /**
82 Equivalent to the error(const String&, helpers::Exception&, int,
83 spi::LoggingEvent&) with the the event parameteter set to
84 null.
85 */
86 virtual void error(const LogString& message, const std::exception& e,
87 int errorCode) const = 0;
88
89 /**
90 This method is normally used to just print the error message
91 passed as a parameter.
92 */
93 virtual void error(const LogString& message) const = 0;
94
95 /**
96 This method is invoked to handle the error.
97
98 @param message The message assoicated with the error.
99 @param e The Exption that was thrown when the error occured.
100 @param errorCode The error code associated with the error.
101 @param event The logging event that the failing appender is asked
102 to log.
103 */
104 virtual void error(const LogString& message, const std::exception& e,
105 int errorCode, const LoggingEventPtr& event) const = 0;
106
107 /**
108 Set the appender for which errors are handled. This method is
109 usually called when the error handler is configured.
110 */
111 virtual void setAppender(const AppenderPtr& appender) = 0;
112
113 /**
114 Set the appender to fallback upon in case of failure.
115 */
116 virtual void setBackupAppender(const AppenderPtr& appender) = 0;
117 };
118
119 LOG4CXX_PTR_DEF(ErrorHandler);
120 } //namespace spi
121} //namespace log4cxx
122
123#if defined(_MSC_VER)
124#pragma warning ( pop )
125#endif
126
127#endif //_LOG4CXX_SPI_ERROR_HANDLER_H
Note: See TracBrowser for help on using the repository browser.