Apache Log4cxx Version 1.0.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
93class LOG4CXX_EXPORT ODBCAppender : public AppenderSkeleton
94{
95 public:
101
102 typedef void* SQLHDBC;
103 typedef void* SQLHENV;
104 typedef void* SQLHANDLE;
105 typedef short SQLSMALLINT;
106
108 virtual ~ODBCAppender();
109
113 void setOption(const LogString& option, const LogString& value) override;
114
118 void activateOptions(helpers::Pool& p) override;
119
123 void append(const spi::LoggingEventPtr& event, helpers::Pool&) override;
124
133 protected:
134 LogString getLogStatement(const spi::LoggingEventPtr& event,
135 helpers::Pool& p) const;
136
145 virtual void execute(const LogString& sql,
146 log4cxx::helpers::Pool& p) /*throw(SQLException)*/;
147
155 virtual void closeConnection(SQLHDBC con);
156
163 virtual SQLHDBC getConnection(log4cxx::helpers::Pool& p) /*throw(SQLException)*/;
164
169 public:
170 void close() override;
171
179 virtual void flushBuffer(log4cxx::helpers::Pool& p);
180
184 bool requiresLayout() const override
185 {
186 return true;
187 }
188
192 void setSql(const LogString& s);
193
197 const LogString& getSql() const;
198
199
200 void setUser(const LogString& user);
201
202 void setURL(const LogString& url);
203
204 void setPassword(const LogString& password);
205
206 void setBufferSize(size_t newBufferSize);
207
208 const LogString& getUser() const;
209
210 const LogString& getURL() const;
211
212 const LogString& getPassword() const;
213
214 size_t getBufferSize() const;
215 private:
217 ODBCAppender& operator=(const ODBCAppender&);
218#if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR_T || defined(WIN32) || defined(_WIN32)
219 static void encode(wchar_t** dest, const LogString& src,
221#endif
222 static void encode(unsigned short** dest, const LogString& src,
224
225 protected:
226 struct ODBCAppenderPriv;
227}; // class ODBCAppender
229
230} // namespace db
231} // namespace log4cxx
232
233#endif // _LOG4CXX_DB_ODBC_APPENDER_H
Implementation base class for all appenders.
Definition: appenderskeleton.h:41
Definition: odbcappender.h:94
void * SQLHENV
Definition: odbcappender.h:103
const LogString & getUser() const
void setBufferSize(size_t newBufferSize)
void setUser(const LogString &user)
const LogString & getSql() const
Returns pre-formated statement eg: insert into LogTable (msg) values ("%m")
void setPassword(const LogString &password)
const LogString & getPassword() const
void setURL(const LogString &url)
void * SQLHDBC
Definition: odbcappender.h:102
void * SQLHANDLE
Definition: odbcappender.h:104
void setSql(const LogString &s)
Set pre-formated statement eg: insert into LogTable (msg) values ("%m")
const LogString & getURL() const
short SQLSMALLINT
Definition: odbcappender.h:105
size_t getBufferSize() const
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(ODBCAppender)
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