Apache Log4cxx  Version 1.3.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
27#if LOG4CXX_EVENTS_AT_EXIT
28#include <log4cxx/private/atexitregistry.h>
29#endif
30
31#include <list>
32#include <memory>
33
34namespace LOG4CXX_NS
35{
36namespace db
37{
38class LOG4CXX_EXPORT SQLException : public LOG4CXX_NS::helpers::Exception
39{
40 public:
41 SQLException(short fHandleType,
42 void* hInput, const char* prolog,
43 LOG4CXX_NS::helpers::Pool& p);
44 SQLException(const char* msg);
46 private:
47 const char* formatMessage(short fHandleType,
48 void* hInput, const char* prolog,
49 LOG4CXX_NS::helpers::Pool& p);
50};
51
143{
144 public:
150
151 typedef void* SQLHDBC;
152 typedef void* SQLHENV;
153 typedef void* SQLHANDLE;
154 typedef short SQLSMALLINT;
155
157 virtual ~ODBCAppender();
158
177 void setOption(const LogString& option, const LogString& value) override;
178
182 void activateOptions(helpers::Pool& p) override;
183
187 void append(const spi::LoggingEventPtr& event, helpers::Pool&) override;
188
189 protected:
193 LogString getLogStatement(const spi::LoggingEventPtr& event,
194 helpers::Pool& p) const;
195
200 virtual void execute(const LogString& sql,
201 LOG4CXX_NS::helpers::Pool& p) /*throw(SQLException)*/;
202
210 virtual void closeConnection(SQLHDBC con);
211
218 virtual SQLHDBC getConnection(LOG4CXX_NS::helpers::Pool& p) /*throw(SQLException)*/;
219
224 public:
225 void close() override;
226
234 virtual void flushBuffer(LOG4CXX_NS::helpers::Pool& p);
235
239 bool requiresLayout() const override;
240
244 void setSql(const LogString& s);
245
249 const LogString& getSql() const;
250
251
252 void setUser(const LogString& user);
253
254 void setURL(const LogString& url);
255
256 void setPassword(const LogString& password);
257
258 void setBufferSize(size_t newBufferSize);
259
260 const LogString& getUser() const;
261
262 const LogString& getURL() const;
263
264 const LogString& getPassword() const;
265
266 size_t getBufferSize() const;
267 private:
269 ODBCAppender& operator=(const ODBCAppender&);
270#if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR_T || defined(WIN32) || defined(_WIN32)
271 static void encode(wchar_t** dest, const LogString& src,
272 LOG4CXX_NS::helpers::Pool& p);
273#endif
274 static void encode(unsigned short** dest, const LogString& src,
275 LOG4CXX_NS::helpers::Pool& p);
276
277 protected:
278 struct ODBCAppenderPriv;
279}; // class ODBCAppender
281
282} // namespace db
283} // namespace log4cxx
284
285#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:143
void * SQLHENV
Definition: odbcappender.h:152
void * SQLHDBC
Definition: odbcappender.h:151
void * SQLHANDLE
Definition: odbcappender.h:153
short SQLSMALLINT
Definition: odbcappender.h:154
Definition: odbcappender.h:39
SQLException(const char *msg)
SQLException(const SQLException &src)
SQLException(short fHandleType, void *hInput, const char *prolog, log4cxx::helpers::Pool &p)
#define LOG4CXX_EXPORT
Definition: log4cxx.h:101
#define LOG4CXX_PTR_DEF(T)
Definition: log4cxx.h:64
#define LOG4CXX_NS
Definition: log4cxx.h:104
std::basic_string< logchar > LogString
Definition: logstring.h:60
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:158
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:152
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:43
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:164
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:146