Apache Log4cxx Version 1.1.0
Loading...
Searching...
No Matches
odbcappender.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_DB_ODBC_APPENDER_H
19#define _LOG4CXX_DB_ODBC_APPENDER_H
20
21#include <log4cxx/log4cxx.h>
22
26#include <list>
27#include <memory>
28
29namespace log4cxx
30{
31namespace db
32{
33class LOG4CXX_EXPORT SQLException : public log4cxx::helpers::Exception
34{
35 public:
36 SQLException(short fHandleType,
37 void* hInput, const char* prolog,
39 SQLException(const char* msg);
41 private:
42 const char* formatMessage(short fHandleType,
43 void* hInput, const char* prolog,
45};
46
137class LOG4CXX_EXPORT ODBCAppender : public AppenderSkeleton
138{
139 public:
145
146 typedef void* SQLHDBC;
147 typedef void* SQLHENV;
148 typedef void* SQLHANDLE;
149 typedef short SQLSMALLINT;
150
152 virtual ~ODBCAppender();
153
172 void setOption(const LogString& option, const LogString& value) override;
173
177 void activateOptions(helpers::Pool& p) override;
178
182 void append(const spi::LoggingEventPtr& event, helpers::Pool&) override;
183
184 protected:
188 LogString getLogStatement(const spi::LoggingEventPtr& event,
189 helpers::Pool& p) const;
190
195 virtual void execute(const LogString& sql,
196 log4cxx::helpers::Pool& p) /*throw(SQLException)*/;
197
205 virtual void closeConnection(SQLHDBC con);
206
213 virtual SQLHDBC getConnection(log4cxx::helpers::Pool& p) /*throw(SQLException)*/;
214
219 public:
220 void close() override;
221
229 virtual void flushBuffer(log4cxx::helpers::Pool& p);
230
234 bool requiresLayout() const override;
235
239 void setSql(const LogString& s);
240
244 const LogString& getSql() const;
245
246
247 void setUser(const LogString& user);
248
249 void setURL(const LogString& url);
250
251 void setPassword(const LogString& password);
252
253 void setBufferSize(size_t newBufferSize);
254
255 const LogString& getUser() const;
256
257 const LogString& getURL() const;
258
259 const LogString& getPassword() const;
260
261 size_t getBufferSize() const;
262 private:
264 ODBCAppender& operator=(const ODBCAppender&);
265#if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR_T || defined(WIN32) || defined(_WIN32)
266 static void encode(wchar_t** dest, const LogString& src,
268#endif
269 static void encode(unsigned short** dest, const LogString& src,
271
272 protected:
273 struct ODBCAppenderPriv;
274}; // class ODBCAppender
276
277} // namespace db
278} // namespace log4cxx
279
280#endif // _LOG4CXX_DB_ODBC_APPENDER_H
Implementation base class for all appenders.
Definition: appenderskeleton.h:41
The ODBCAppender sends log events to a database.
Definition: odbcappender.h:138
void * SQLHENV
Definition: odbcappender.h:147
void * SQLHDBC
Definition: odbcappender.h:146
void * SQLHANDLE
Definition: odbcappender.h:148
short SQLSMALLINT
Definition: odbcappender.h:149
Definition: odbcappender.h:34
SQLException(const char *msg)
SQLException(const SQLException &src)
SQLException(short fHandleType, void *hInput, const char *prolog, log4cxx::helpers::Pool &p)
The class Exception and its subclasses indicate conditions that a reasonable application might want t...
Definition: exception.h:38
Definition: pool.h:33
LOG4CXX_PTR_DEF(DBAppender)
Definition: configuration.h:25
std::basic_string< logchar > LogString
Definition: logstring.h:60
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:157
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:151
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:42
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:163
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:145