You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ca...@apache.org on 2007/12/11 22:14:14 UTC

svn commit: r603359 - in /logging/log4cxx/trunk: ./ src/main/cpp/ src/main/include/log4cxx/ src/main/include/log4cxx/db/ src/main/include/log4cxx/private/

Author: carnold
Date: Tue Dec 11 13:14:12 2007
New Revision: 603359

URL: http://svn.apache.org/viewvc?rev=603359&view=rev
Log:
LOGCXX-215: Eliminate reference to sqlext.h in odbcappender.h

Modified:
    logging/log4cxx/trunk/INSTALL
    logging/log4cxx/trunk/NOTICE
    logging/log4cxx/trunk/configure.in
    logging/log4cxx/trunk/src/main/cpp/class.cpp
    logging/log4cxx/trunk/src/main/cpp/odbcappender.cpp
    logging/log4cxx/trunk/src/main/include/log4cxx/db/odbcappender.h
    logging/log4cxx/trunk/src/main/include/log4cxx/log4cxx.hw
    logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.h.in
    logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.hw

Modified: logging/log4cxx/trunk/INSTALL
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/INSTALL?rev=603359&r1=603358&r2=603359&view=diff
==============================================================================
--- logging/log4cxx/trunk/INSTALL (original)
+++ logging/log4cxx/trunk/INSTALL Tue Dec 11 13:14:12 2007
@@ -229,7 +229,7 @@
 --with-logchar= utf-8 | wchar_t: Specify internal character type. 
 
 
-SMTP support (SMTPAppender) can be disabled through option -with-SMTP
+SMTP support (SMTPAppender) can be disabled through option --with-SMTP
         * "libesmtp": libesmtp library (http://www.stafford.uklinux.net/libesmtp/)
         * "no" (default): no SMTP support
 
@@ -238,11 +238,17 @@
 --enable-html-docs: generate HTML documentation with doxygen
 --enable-latex-docs: generate Latex documentation with doxygen
  
-ODBC support (ODBCAppender) can be added through option -with-ODBC
+ODBC support (ODBCAppender) can be added through option --with-ODBC
         * "unixODBC" : unixODBC library (http://www.unixodbc.org)
         * "iODBC" : iODBC library (http://www.iodbc.org)
         * "Microsoft" : Microsoft ODBC library
         * "no" (default) : no ODBC support
+        
+SMTP and ODBC support involving compiling and linking with
+that are not licensed under the Apache Software License.
+You should review the corresponding licenses and understand
+there implications before distributing derived works with
+those features enabled.
 
 
 

Modified: logging/log4cxx/trunk/NOTICE
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/NOTICE?rev=603359&r1=603358&r2=603359&view=diff
==============================================================================
--- logging/log4cxx/trunk/NOTICE (original)
+++ logging/log4cxx/trunk/NOTICE Tue Dec 11 13:14:12 2007
@@ -1,2 +1,5 @@
+Apache log4cxx
+Copyright 2004-2007 The Apache Software Foundation
+
 This product includes software developed by
 The Apache Software Foundation (http://www.apache.org/).

Modified: logging/log4cxx/trunk/configure.in
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/configure.in?rev=603359&r1=603358&r2=603359&view=diff
==============================================================================
--- logging/log4cxx/trunk/configure.in (original)
+++ logging/log4cxx/trunk/configure.in Tue Dec 11 13:14:12 2007
@@ -207,16 +207,14 @@
         [ac_with_odbc=no])
 case "$ac_with_odbc" in
     Microsoft)
-        AC_DEFINE(HAVE_MS_ODBC, 1, ODBC support through Microsoft ODBC.)
-        AC_DEFINE(HAVE_ODBC, 1, ODBC support)
+        AC_SUBST(HAS_ODBC, 1, ODBC support)
         AC_MSG_RESULT(Microsoft)
         LIBS_ODBC="-lodbc32"
         ;;
     unixODBC)
         AC_MSG_RESULT(unixODBC)
         AC_CHECK_HEADER(sqlext.h,, AC_MSG_ERROR(unixODBC not found !))
-        AC_DEFINE(HAVE_UNIX_ODBC, 1, ODBC support through unixODBC.)
-        AC_DEFINE(HAVE_ODBC, 1, ODBC support)
+        AC_SUBST(HAS_ODBC, 1, ODBC support)
         LIBS_ODBC="-lodbc"
         ;;
     iODBC)
@@ -224,8 +222,7 @@
         AC_CHECK_PROG(IODBC_CONFIG, iodbc-config, yes, no)
         if test "x$IODBC_CONFIG" = "xyes"
         then
-                AC_DEFINE(HAVE_I_ODBC, 1, ODBC support through iODBC.)
-                AC_DEFINE(HAVE_ODBC, 1, ODBC support)
+                AC_SUBST(HAS_ODBC, 1, ODBC support)
                 LIBS_ODBC="`iodbc-config --libs`"
                 CPPFLAGS_ODBC="`iodbc-config --cflags`"
         else
@@ -233,6 +230,7 @@
         fi
         ;;
         no)
+        AC_SUBST(HAS_ODBC, 0, No ODBC support)
         AC_MSG_RESULT(no)
         ;;
     *)

Modified: logging/log4cxx/trunk/src/main/cpp/class.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/class.cpp?rev=603359&r1=603358&r2=603359&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/class.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/class.cpp Tue Dec 11 13:14:12 2007
@@ -30,9 +30,7 @@
 #include <log4cxx/asyncappender.h>
 #include <log4cxx/consoleappender.h>
 #include <log4cxx/fileappender.h>
-#ifdef LOG4CXX_HAVE_ODBC
 #include <log4cxx/db/odbcappender.h>
-#endif
 #if (defined(WIN32) || defined(_WIN32)) && !defined(_WIN32_WCE)
 #include <log4cxx/nt/nteventlogappender.h>
 #endif
@@ -40,9 +38,7 @@
 #include <log4cxx/nt/outputdebugstringappender.h>
 #endif
 #include <log4cxx/rolling/rollingfileappender.h>
-#if LOG4CXX_HAVE_SMTP
 #include <log4cxx/net/smtpappender.h>
-#endif
 #include <log4cxx/net/socketappender.h>
 #include <log4cxx/net/sockethubappender.h>
 #include <log4cxx/helpers/datagramsocket.h>

Modified: logging/log4cxx/trunk/src/main/cpp/odbcappender.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/odbcappender.cpp?rev=603359&r1=603358&r2=603359&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/odbcappender.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/odbcappender.cpp Tue Dec 11 13:14:12 2007
@@ -14,22 +14,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
-#if defined(WIN32) || defined(_WIN32)
-#include <windows.h>
-#endif
-
 #include <log4cxx/db/odbcappender.h>
-
-#ifdef LOG4CXX_HAVE_ODBC
-
 #include <log4cxx/helpers/loglog.h>
 #include <log4cxx/helpers/optionconverter.h>
 #include <log4cxx/helpers/stringhelper.h>
 #include <log4cxx/helpers/transcoder.h>
 #include <log4cxx/patternlayout.h>
 
+#if !defined(LOG4CXX)
+#define LOG4CXX 1
+#endif
+#include <log4cxx/private/log4cxx_private.h>
+#if LOG4CXX_HAVE_ODBC
+#if defined(WIN32) || defined(_WIN32)
+#include <windows.h>
+#endif
+#include <sqlext.h>
+#endif
+
+
 using namespace log4cxx;
 using namespace log4cxx::helpers;
 using namespace log4cxx::db;
@@ -40,7 +43,7 @@
 
 
 ODBCAppender::ODBCAppender()
-: connection(SQL_NULL_HDBC), env(SQL_NULL_HENV), bufferSize(1)
+: connection(0), env(0), bufferSize(1)
 {
 }
 
@@ -79,12 +82,21 @@
    }
 }
 
+void ODBCAppender::activateOptions(log4cxx::helpers::Pool&) {
+#if !LOG4CXX_HAVE_ODBC
+    LogLog::error(LOG4CXX_STR("Can not activate ODBCAppender unless compiled with ODBC support."));
+#endif
+}
+
+
 void ODBCAppender::append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p)
 {
+#if LOG4CXX_HAVE_ODBC
    buffer.push_back(event);
 
    if (buffer.size() >= bufferSize)
       flushBuffer();
+#endif      
 }
 
 LogString ODBCAppender::getLogStatement(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) const
@@ -96,6 +108,7 @@
 
 void ODBCAppender::execute(const LogString& sql)
 {
+#if LOG4CXX_HAVE_ODBC
    SQLRETURN ret;
    SQLHDBC con = SQL_NULL_HDBC;
    SQLHSTMT stmt = SQL_NULL_HSTMT;
@@ -129,20 +142,22 @@
    }
    SQLFreeHandle(SQL_HANDLE_STMT, stmt);
    closeConnection(con);
-
-   //tcout << LOG4CXX_STR("Execute: ") << sql << std::endl;
+#else
+    throw SQLException("log4cxx build without ODBC support");
+#endif
 }
 
 /* The default behavior holds a single connection open until the appender
 is closed (typically when garbage collected).*/
-void ODBCAppender::closeConnection(SQLHDBC con)
+void ODBCAppender::closeConnection(ODBCAppender::SQLHDBC con)
 {
 }
 
-std::string ODBCAppender::GetErrorMessage(SQLSMALLINT fHandleType, SQLHANDLE hInput, const char* szMsg )
+std::string ODBCAppender::GetErrorMessage(ODBCAppender::SQLSMALLINT fHandleType, 
+    ODBCAppender::SQLHANDLE hInput, const char* szMsg )
 {
+#if LOG4CXX_HAVE_ODBC
    SQLCHAR       SqlState[6];
-   SQLCHAR       SQLStmt[100];
    SQLCHAR       Msg[SQL_MAX_MESSAGE_LENGTH];
    SQLINTEGER    NativeError;
    SQLSMALLINT   i;
@@ -162,13 +177,17 @@
    }
 
    return strReturn;
+#else
+   return "log4cxx built without ODBC support";
+#endif   
 }
 
 
 
 
-SQLHDBC ODBCAppender::getConnection()
+ODBCAppender::SQLHDBC ODBCAppender::getConnection()
 {
+#if LOG4CXX_HAVE_ODBC
    SQLRETURN ret;
 
    if (env == SQL_NULL_HENV)
@@ -225,6 +244,9 @@
    }
 
    return connection;
+#else
+   return 0;
+#endif   
 }
 
 void ODBCAppender::close()
@@ -241,7 +263,7 @@
       errorHandler->error(LOG4CXX_STR("Error closing connection"),
          e, ErrorCode::GENERIC_FAILURE);
    }
-
+#if LOG4CXX_HAVE_ODBC
    if (connection != SQL_NULL_HDBC)
    {
       SQLDisconnect(connection);
@@ -252,7 +274,7 @@
    {
       SQLFreeHandle(SQL_HANDLE_ENV, env);
    }
-
+#endif
    this->closed = true;
 }
 
@@ -299,5 +321,3 @@
       }
    }
 }
-
-#endif //LOG4CXX_HAVE_ODBC

Modified: logging/log4cxx/trunk/src/main/include/log4cxx/db/odbcappender.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/db/odbcappender.h?rev=603359&r1=603358&r2=603359&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/db/odbcappender.h (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/db/odbcappender.h Tue Dec 11 13:14:12 2007
@@ -19,19 +19,11 @@
 #define _LOG4CXX_DB_ODBC_APPENDER_H
 #include <log4cxx/log4cxx.h>
 
-#ifdef LOG4CXX_HAVE_ODBC
-
 #include <log4cxx/helpers/exception.h>
 #include <log4cxx/appenderskeleton.h>
 #include <log4cxx/spi/loggingevent.h>
 #include <list>
 
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
-#include <sqlext.h>
-
 namespace log4cxx
 {
         namespace db
@@ -48,7 +40,6 @@
                 };
 
                 class ODBCAppender;
-                typedef helpers::ObjectPtrT<ODBCAppender> ODBCAppenderPtr;
 
                 /**
                 <p><b>WARNING: This version of ODBCAppender
@@ -114,6 +105,11 @@
                         */
                         LogString databasePassword;
 
+                        typedef void* SQLHDBC;
+                        typedef void* SQLHENV;
+                        typedef void* SQLHANDLE;
+                        typedef short SQLSMALLINT;
+
                         /**
                         * Connection used by default.  The connection is opened the first time it
                         * is needed and then held open until the appender is closed (usually at
@@ -136,7 +132,7 @@
                         LogString sqlStatement;
 
                         /**
-                        * size of LoggingEvent buffer before writting to the database.
+                        * size of LoggingEvent buffer before writing to the database.
                         * Default is 1.
                         */
                         size_t bufferSize;
@@ -162,6 +158,11 @@
                         virtual void setOption(const LogString& option, const LogString& value);
 
                         /**
+                        Activate the specified options.
+                        */
+                        virtual void activateOptions(log4cxx::helpers::Pool& p);
+
+                        /**
                         * Adds the event to the buffer.  When full the buffer is flushed.
                         */
                   void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool&);
@@ -269,9 +270,13 @@
 
                         inline size_t getBufferSize() const
                                 { return bufferSize; }
+                private:
+                        ODBCAppender(const ODBCAppender&);
+                        ODBCAppender& operator=(const ODBCAppender&);
                 }; // class ODBCAppender
+                typedef helpers::ObjectPtrT<ODBCAppender> ODBCAppenderPtr;
+                
     } // namespace db
 } // namespace log4cxx
 
-#endif // LOG4CXX_HAVE_ODBC
-#endif // _LOG4CXX_NET_SOCKET_APPENDER_H
+#endif // _LOG4CXX_DB_ODBC_APPENDER_H

Modified: logging/log4cxx/trunk/src/main/include/log4cxx/log4cxx.hw
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/log4cxx.hw?rev=603359&r1=603358&r2=603359&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/log4cxx.hw (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/log4cxx.hw Tue Dec 11 13:14:12 2007
@@ -61,9 +61,5 @@
 #define LOG4CXX_LOCALE_ENCODING_ISO_8859_1 0
 #define LOG4CXX_LOCALE_ENCODING_US_ASCII 0
 
-#if !defined(_WIN32_WCE)
-#define LOG4CXX_HAVE_ODBC 1
-#endif
-
 #endif
 

Modified: logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.h.in
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.h.in?rev=603359&r1=603358&r2=603359&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.h.in (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.h.in Tue Dec 11 13:14:12 2007
@@ -50,11 +50,8 @@
 #define LOG4CXX_LOCALE_ENCODING_US_ASCII 0
 
 
-//
-//   Capabilities should be checked in client code by
-//       attempting creation of the corresponding appender.
-//
 #define LOG4CXX_HAVE_LIBESMTP @HAS_LIBESMTP@
 #define LOG4CXX_HAVE_SYSLOG @HAS_SYSLOG@
+#define LOG4CXX_HAVE_ODBC @HAS_ODBC@
 
 #endif

Modified: logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.hw
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.hw?rev=603359&r1=603358&r2=603359&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.hw (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.hw Tue Dec 11 13:14:12 2007
@@ -70,5 +70,8 @@
 #define LOG4CXX_MEMSET_IOS_BASE 1
 #endif
 
+#if !defined(_WIN32_WCE)
+#define LOG4CXX_HAVE_ODBC 1
+#endif
 
 #endif