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
157 void setOption(const LogString& option, const LogString& value) override;
158
162 void activateOptions(helpers::Pool& p) override;
163
167 void append(const spi::LoggingEventPtr& event, helpers::Pool&) override;
168
169 protected:
173 LogString getLogStatement(const spi::LoggingEventPtr& event,
174 helpers::Pool& p) const;
175
180 virtual void execute(const LogString& sql,
181 log4cxx::helpers::Pool& p) /*throw(SQLException)*/;
182
190 virtual void closeConnection(SQLHDBC con);
191
198 virtual SQLHDBC getConnection(log4cxx::helpers::Pool& p) /*throw(SQLException)*/;
199
204 public:
205 void close() override;
206
214 virtual void flushBuffer(log4cxx::helpers::Pool& p);
215
219 bool requiresLayout() const override;
220
224 void setSql(const LogString& s);
225
229 const LogString& getSql() const;
230
231
232 void setUser(const LogString& user);
233
234 void setURL(const LogString& url);
235
236 void setPassword(const LogString& password);
237
238 void setBufferSize(size_t newBufferSize);
239
240 const LogString& getUser() const;
241
242 const LogString& getURL() const;
243
244 const LogString& getPassword() const;
245
246 size_t getBufferSize() const;
247 private:
249 ODBCAppender& operator=(const ODBCAppender&);
250#if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR_T || defined(WIN32) || defined(_WIN32)
251 static void encode(wchar_t** dest, const LogString& src,
253#endif
254 static void encode(unsigned short** dest, const LogString& src,
256
257 protected:
258 struct ODBCAppenderPriv;
259}; // class ODBCAppender
261
262} // namespace db
263} // namespace log4cxx
264
265#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