tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r1222604 - in /tuscany/sca-cpp/trunk: components/cache/ components/chat/ components/constdb/ components/filedb/ components/http/ components/kvdb/ components/log/ components/queue/ components/sqldb/ components/webservice/ kernel/ modules/htt...
Date Fri, 23 Dec 2011 08:18:39 GMT
Author: jsdelfino
Date: Fri Dec 23 08:18:38 2011
New Revision: 1222604

URL: http://svn.apache.org/viewvc?rev=1222604&view=rev
Log:
Use HTTPD ap_log_error instead of stderr to log when running inside HTTPD, to get log piping
and rotation to work.

Modified:
    tuscany/sca-cpp/trunk/components/cache/datacache.cpp
    tuscany/sca-cpp/trunk/components/cache/memcache.cpp
    tuscany/sca-cpp/trunk/components/cache/memocache.cpp
    tuscany/sca-cpp/trunk/components/chat/chat-sender.cpp
    tuscany/sca-cpp/trunk/components/chat/chat-sender2.cpp
    tuscany/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp
    tuscany/sca-cpp/trunk/components/constdb/constdb.cpp
    tuscany/sca-cpp/trunk/components/filedb/filedb.cpp
    tuscany/sca-cpp/trunk/components/http/httpdelete.cpp
    tuscany/sca-cpp/trunk/components/http/httpget.cpp
    tuscany/sca-cpp/trunk/components/http/httppatch.cpp
    tuscany/sca-cpp/trunk/components/http/httppost.cpp
    tuscany/sca-cpp/trunk/components/http/httpput.cpp
    tuscany/sca-cpp/trunk/components/kvdb/kvdb.cpp
    tuscany/sca-cpp/trunk/components/log/log.cpp
    tuscany/sca-cpp/trunk/components/log/logger.cpp
    tuscany/sca-cpp/trunk/components/log/scribe.hpp
    tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp
    tuscany/sca-cpp/trunk/components/queue/queue-sender.cpp
    tuscany/sca-cpp/trunk/components/sqldb/sqldb.cpp
    tuscany/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp
    tuscany/sca-cpp/trunk/components/webservice/axis2-service.cpp
    tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp
    tuscany/sca-cpp/trunk/components/webservice/webservice-listener.cpp
    tuscany/sca-cpp/trunk/kernel/fstream.hpp
    tuscany/sca-cpp/trunk/kernel/monad.hpp
    tuscany/sca-cpp/trunk/modules/http/httpd-conf
    tuscany/sca-cpp/trunk/modules/http/httpd.hpp
    tuscany/sca-cpp/trunk/modules/http/mod-openauth.cpp
    tuscany/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp
    tuscany/sca-cpp/trunk/modules/java/mod-java.cpp
    tuscany/sca-cpp/trunk/modules/js/eval.hpp
    tuscany/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
    tuscany/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
    tuscany/sca-cpp/trunk/modules/python/mod-python.cpp
    tuscany/sca-cpp/trunk/modules/server/mod-eval.cpp
    tuscany/sca-cpp/trunk/modules/server/mod-wiring.cpp

Modified: tuscany/sca-cpp/trunk/components/cache/datacache.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/datacache.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/datacache.cpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/datacache.cpp Fri Dec 23 08:18:38 2011
@@ -31,6 +31,7 @@
  * meantime the updates will be retrieved from the level1 cache).
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/cache/memcache.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/memcache.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/memcache.cpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/memcache.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * Memcached-based cache component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/cache/memocache.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/memocache.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/memocache.cpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/memocache.cpp Fri Dec 23 08:18:38 2011
@@ -29,6 +29,7 @@
  * cache without actually applying the function.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/chat/chat-sender.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/chat-sender.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/chat-sender.cpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/chat-sender.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * XMPP chat sender component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/chat/chat-sender2.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/chat-sender2.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/chat-sender2.cpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/chat-sender2.cpp Fri Dec 23 08:18:38 2011
@@ -25,6 +25,7 @@
  * input data from component references instead of function parameters.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * XMPP chat sender/receiver component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/constdb/constdb.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/constdb/constdb.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/constdb/constdb.cpp (original)
+++ tuscany/sca-cpp/trunk/components/constdb/constdb.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * TinyCDB-based database component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/filedb/filedb.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/filedb.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/filedb.cpp (original)
+++ tuscany/sca-cpp/trunk/components/filedb/filedb.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * File based database component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/http/httpdelete.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/httpdelete.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/httpdelete.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/httpdelete.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * HTTP client component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/http/httpget.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/httpget.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/httpget.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/httpget.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * HTTP client component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/http/httppatch.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/httppatch.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/httppatch.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/httppatch.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * HTTP client component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/http/httppost.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/httppost.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/httppost.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/httppost.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * HTTP client component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/http/httpput.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/httpput.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/httpput.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/httpput.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * HTTP client component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/kvdb/kvdb.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/kvdb/kvdb.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/kvdb/kvdb.cpp (original)
+++ tuscany/sca-cpp/trunk/components/kvdb/kvdb.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * LevelDB-based database component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/log/log.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/log/log.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/log/log.cpp (original)
+++ tuscany/sca-cpp/trunk/components/log/log.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * Scribe-based log component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/log/logger.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/log/logger.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/log/logger.cpp (original)
+++ tuscany/sca-cpp/trunk/components/log/logger.cpp Fri Dec 23 08:18:38 2011
@@ -24,6 +24,7 @@
  * and log service invocations.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/log/scribe.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/log/scribe.hpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/log/scribe.hpp (original)
+++ tuscany/sca-cpp/trunk/components/log/scribe.hpp Fri Dec 23 08:18:38 2011
@@ -34,6 +34,7 @@
 #undef PACKAGE_TARNAME
 #undef PACKAGE_VERSION
 #undef VERSION
+#undef OK
 
 // Ignore integer conversion issues in Thrift and Scribe headers
 #ifdef WANT_MAINTAINER_MODE

Modified: tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp (original)
+++ tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * AMQP queue listener component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/queue/queue-sender.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/queue/queue-sender.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/queue/queue-sender.cpp (original)
+++ tuscany/sca-cpp/trunk/components/queue/queue-sender.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * AMQP queue sender component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/sqldb/sqldb.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/sqldb/sqldb.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/sqldb/sqldb.cpp (original)
+++ tuscany/sca-cpp/trunk/components/sqldb/sqldb.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * PostgreSQL-based database component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp (original)
+++ tuscany/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * Axis2/C module that dispatches all server requests to the Tuscany Axis/2C service.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "axis2.hpp"
 
 namespace tuscany {

Modified: tuscany/sca-cpp/trunk/components/webservice/axis2-service.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/webservice/axis2-service.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/webservice/axis2-service.cpp (original)
+++ tuscany/sca-cpp/trunk/components/webservice/axis2-service.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * Axis2/C service implementation that dispatches requests to SCA Web service components.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "value.hpp"
 #include "string.hpp"
 #include "../../modules/http/httpd.hpp"

Modified: tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp (original)
+++ tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp Fri Dec 23 08:18:38
2011
@@ -23,6 +23,7 @@
  * Web service client component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/components/webservice/webservice-listener.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/webservice/webservice-listener.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/webservice/webservice-listener.cpp (original)
+++ tuscany/sca-cpp/trunk/components/webservice/webservice-listener.cpp Fri Dec 23 08:18:38
2011
@@ -23,6 +23,7 @@
  * Web service listener component implementation.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/kernel/fstream.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/fstream.hpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/fstream.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/fstream.hpp Fri Dec 23 08:18:38 2011
@@ -28,12 +28,37 @@
 
 #include <stdio.h>
 #include <stdarg.h>
+
+#ifdef WANT_HTTPD_LOG
+#include <apr_strings.h>
+#include <apr_fnmatch.h>
+#include <apr_lib.h>
+#define APR_WANT_STRFUNC
+#include <apr_want.h>
+#include <apr_base64.h>
+
+#include <httpd.h>
+// Hack to workaround compile error with CLang/LLVM
+#undef strtoul
+// Hack to workaround compile error with HTTPD 2.3.8
+#define new new_
+#include <http_config.h>
+#undef new
+#include <http_main.h>
+#include <http_log.h>
+
+#else
+
 #include <time.h>
 #include <sys/time.h>
 #include <unistd.h>
+
 #ifdef WANT_THREADS
 #include <pthread.h>
 #endif
+
+#endif
+
 #include "string.hpp"
 #include "stream.hpp"
 
@@ -150,6 +175,73 @@ ifstream cin(stdin);
  * Streams used for logging.
  */
 
+#ifdef WANT_HTTPD_LOG
+
+/*
+ * HTTPD-based log stream.
+ */
+class loghstream : public ostream {
+public:
+    loghstream(const int level) : level(level), len(0) {
+    }
+
+    ~loghstream() {
+    }
+
+    ostream& vprintf(const char* fmt, ...) {
+        va_list args;
+        va_start (args, fmt);
+        const int l = vsnprintf(buf + len, (sizeof(buf) - 1) - len, fmt, args);
+        va_end (args);
+        len += l;
+        if (len > (int)(sizeof(buf) - 1))
+            len = sizeof(buf) - 1;
+        return *this;
+    }
+
+    ostream& write(const string& s) {
+        if (s != "\n")
+            return this->vprintf("%s", c_str(s));
+        buf[len] = '\0';
+        ap_log_error(NULL, 0, -1, level, 0, ap_server_conf, "%s", buf);
+        len = 0;
+        return *this;
+    }
+
+    ostream& flush() {
+        return *this;
+    }
+
+private:
+    const int level;
+    int len;
+    char buf[2049];
+};
+
+/**
+ * Info and failure log streams.
+ */
+loghstream cinfo(APLOG_INFO);
+loghstream cfailure(APLOG_ERR);
+
+#ifdef WANT_MAINTAINER_MODE
+
+/**
+ * Debug log stream.
+ */
+loghstream cdebug(APLOG_DEBUG);
+
+/**
+ * Return true if debug log is enabled.
+ */
+const bool isDebugLog() {
+    return APLOG_MODULE_IS_LEVEL(ap_server_conf, APLOG_NO_MODULE, APLOG_DEBUG);
+}
+
+#endif
+
+#else
+
 /**
  * Format the current time.
  */
@@ -166,25 +258,20 @@ const string logTime() {
 }
 
 /*
- * Log stream.
+ * File-based log stream.
  */
 class logfstream : public ostream {
 public:
-    logfstream(FILE* file, const string& type) : file(file), type(type), owner(false),
head(false) {
+    logfstream(FILE* file, const string& type) : file(file), type(type), head(false)
{
     }
 
-    logfstream(const logfstream& os) : file(os.file), type(os.type), owner(false), head(os.head)
{
+    logfstream(const logfstream& os) : file(os.file), type(os.type), head(os.head) {
     }
 
     ~logfstream() {
-        if (!owner)
-            return;
-        if (file == NULL)
-            return;
-        fclose(file);
     }
 
-    logfstream& vprintf(const char* fmt, ...) {
+    ostream& vprintf(const char* fmt, ...) {
         whead();
         va_list args;
         va_start (args, fmt);
@@ -193,7 +280,7 @@ public:
         return *this;
     }
 
-    logfstream& write(const string& s) {
+    ostream& write(const string& s) {
         whead();
         fwrite(c_str(s), 1, length(s), file);
         if (s == "\n")
@@ -201,7 +288,7 @@ public:
         return *this;
     }
 
-    logfstream& flush() {
+    ostream& flush() {
         fflush(file);
         return *this;
     }
@@ -209,7 +296,6 @@ public:
 private:
     FILE* file;
     const string type;
-    bool owner;
     bool head;
 
     const unsigned long tid() const {
@@ -220,7 +306,7 @@ private:
 #endif
     }
 
-    logfstream& whead() {
+    ostream& whead() {
         if (head)
             return *this;
         head = true;
@@ -238,14 +324,29 @@ logfstream cfailure(stderr, "error");
 #ifdef WANT_MAINTAINER_MODE
 
 /**
- * Debug log stream and debug functions.
+ * Debug log stream.
  */
 logfstream cdebug(stderr, "debug");
 
 /**
+ * Return true if debug log is enabled.
+ */
+const bool isDebugLog() {
+    return true;
+}
+
+#endif
+
+#endif
+
+#ifdef WANT_MAINTAINER_MODE
+
+/**
  * Log a debug message.
  */
 const bool debugLog(const string& msg) {
+    if (!isDebugLog())
+        return true;
     gc_scoped_pool();
     cdebug << msg << endl;
     return true;
@@ -255,6 +356,8 @@ const bool debugLog(const string& msg) {
  * Log a debug message and a value.
  */
 template<typename V> const bool debugLog(const V& v, const string& msg) {
+    if (!isDebugLog())
+        return true;
     gc_scoped_pool();
     cdebug << msg << ": " << v << endl;
     return true;

Modified: tuscany/sca-cpp/trunk/kernel/monad.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/monad.hpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/monad.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/monad.hpp Fri Dec 23 08:18:38 2011
@@ -278,20 +278,15 @@ template<typename V, typename F> const l
  */
 template<typename V, typename F> const failable<V, F> mkfailure(const F&
f, const bool log = true) {
 #ifdef WANT_MAINTAINER_MODE
-    if (log) {
-        ostringstream os;
-        os << f;
-        if (length(str(os)) != 0)
-            debug(f, "failable::mkfailure");
-    }
-#else
+    if (!log)
+        debug(f, "failable::mkfailure");
+#endif
     if (log) {
         ostringstream os;
         os << f;
         if (length(str(os)) != 0)
             cfailure << "failable::mkfailure" << ": " << f << endl;
     }
-#endif
     return failable<V, F>(false, f);
 }
 

Modified: tuscany/sca-cpp/trunk/modules/http/httpd-conf
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/http/httpd-conf?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/http/httpd-conf (original)
+++ tuscany/sca-cpp/trunk/modules/http/httpd-conf Fri Dec 23 08:18:38 2011
@@ -81,7 +81,6 @@ HostNameLookups Off
 # [timestamp] [access] remote-host remote-ident remote-user "request-line"
 # status response-size "referrer" "user-agent" "user-track" local-IP
 # virtual-host response-time bytes-received bytes-sent
-LogLevel notice
 LogFormat "[%{%a %b %d %H:%M:%S %Y}t] [access] %h %l %u \"%r\" %>s %b \"%{Referer}i\"
\"%{User-agent}i\" \"%{cookie}n\" %A %V %D %I %O" combined
 Include conf/log.conf
 
@@ -152,6 +151,7 @@ EOF
 # Configure logging
 cat >$root/conf/log.conf <<EOF
 # Generated by: httpd-conf $*
+LogLevel notice
 ErrorLog $root/logs/error_log
 CustomLog $root/logs/access_log combined
 

Modified: tuscany/sca-cpp/trunk/modules/http/httpd.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/http/httpd.hpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/http/httpd.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/http/httpd.hpp Fri Dec 23 08:18:38 2011
@@ -672,7 +672,6 @@ const char* debugOptional(const char* s)
  * Log a header
  */
 int debugHeader(unused void* r, const char* key, const char* value) {
-    gc_scoped_pool();
     cdebug << "  header key: " << key << ", value: " << value <<
endl;
     return 1;
 }
@@ -681,7 +680,6 @@ int debugHeader(unused void* r, const ch
  * Log an environment variable
  */
 int debugEnv(unused void* r, const char* key, const char* value) {
-    gc_scoped_pool();
     cdebug << "  var key: " << key << ", value: " << value <<
endl;
     return 1;
 }
@@ -690,7 +688,6 @@ int debugEnv(unused void* r, const char*
  * Log a note.
  */
 int debugNote(unused void* r, const char* key, const char* value) {
-    gc_scoped_pool();
     cdebug << "  note key: " << key << ", value: " << value <<
endl;
     return 1;
 }
@@ -699,6 +696,8 @@ int debugNote(unused void* r, const char
  * Log a request.
  */
 const bool debugRequest(request_rec* r, const string& msg) {
+    if (!isDebugLog())
+        return true;
     gc_scoped_pool();
     cdebug << msg << ":" << endl;
     cdebug << "  unparsed uri: " << debugOptional(r->unparsed_uri) <<
endl;

Modified: tuscany/sca-cpp/trunk/modules/http/mod-openauth.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/http/mod-openauth.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/http/mod-openauth.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/http/mod-openauth.cpp Fri Dec 23 08:18:38 2011
@@ -33,6 +33,7 @@
 
 #include <sys/stat.h>
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "stream.hpp"
 #include "list.hpp"
@@ -79,13 +80,20 @@ public:
 #ifdef WANT_MAINTAINER_MODE
 
 /**
- * Log a session entry.
+ * Log session entries.
  */
-int debugSession(unused void* r, const char* key, const char* value) {
+int debugSessionEntry(unused void* r, const char* key, const char* value) {
     cdebug << "  session key: " << key << ", value: " << value <<
endl;
     return 1;
 }
 
+const bool debugSession(request_rec* r, session_rec* z) {
+    if (!isDebugLog())
+        return true;
+    apr_table_do(debugSessionEntry, r, z->entries, NULL);
+    return true;
+}
+
 #endif
 
 /**
@@ -103,7 +111,7 @@ const failable<value> userInfoFromSessio
     if (z == NULL)
         return mkfailure<value>("Couldn't retrieve user session");
 #ifdef WANT_MAINTAINER_MODE
-    apr_table_do(debugSession, r, z->entries, NULL);
+    debugSession(r, z);
 #endif
 
     if (ap_session_get_fn == NULL)
@@ -225,8 +233,8 @@ static int checkAuthn(request_rec *r) {
         if (hasContent(info)) {
 
             // Try to authenticate the request
-            const value cinfo = content(info);
-            const failable<int> authz = checkAuthnz(cadr(assoc<value>("id", cinfo)),
cadr(assoc<value>("password", cinfo)), r);
+            const value uinfo = content(info);
+            const failable<int> authz = checkAuthnz(cadr(assoc<value>("id", uinfo)),
cadr(assoc<value>("password", uinfo)), r);
             if (!hasContent(authz)) {
 
                 // Authentication failed, redirect to login page
@@ -236,7 +244,7 @@ static int checkAuthn(request_rec *r) {
 
             // Successfully authenticated, store the user info in the request
             r->ap_auth_type = const_cast<char*>(atype);
-            return httpd::reportStatus(authenticated(cinfo, r));
+            return httpd::reportStatus(authenticated(uinfo, r));
         }
     }
 
@@ -254,8 +262,8 @@ static int checkAuthn(request_rec *r) {
         if (hasContent(info)) {
 
             // Try to authenticate the request
-            const value cinfo = content(info);
-            const failable<int> authz = checkAuthnz(cadr(assoc<value>("id", cinfo)),
cadr(assoc<value>("password", cinfo)), r);
+            const value uinfo = content(info);
+            const failable<int> authz = checkAuthnz(cadr(assoc<value>("id", uinfo)),
cadr(assoc<value>("password", uinfo)), r);
             if (!hasContent(authz)) {
 
                 // Authentication failed, redirect to login page
@@ -265,7 +273,7 @@ static int checkAuthn(request_rec *r) {
 
             // Successfully authenticated, store the user info in the request
             r->ap_auth_type = const_cast<char*>(atype);
-            return httpd::reportStatus(authenticated(cinfo, r));
+            return httpd::reportStatus(authenticated(uinfo, r));
         }
     }
 

Modified: tuscany/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp Fri Dec 23 08:18:38 2011
@@ -25,6 +25,7 @@
 
 #include <sys/stat.h>
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "stream.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/modules/java/mod-java.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/java/mod-java.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/java/mod-java.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/java/mod-java.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * HTTPD module used to eval Java component implementations.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/modules/js/eval.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/js/eval.hpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/js/eval.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/js/eval.hpp Fri Dec 23 08:18:38 2011
@@ -52,13 +52,8 @@ namespace js {
  * Report Javascript errors.
  */
 void reportError(unused ::JSContext *cx, const char *message, JSErrorReport *report) {
-#ifdef WANT_MAINTAINER_MODE
-    cdebug << (const char*)(report->filename? report->filename : "<no filename>")
<< ":"
+    cfailure << (const char*)(report->filename? report->filename : "<no filename>")
<< ":"
             << (int)report->lineno << ":" << message << endl;
-#else
-    cerr << (const char*)(report->filename? report->filename : "<no filename>")
<< ":"
-            << (int)report->lineno << ":" << message << endl;
-#endif
 }
 
 /**

Modified: tuscany/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp Fri Dec 23 08:18:38 2011
@@ -30,6 +30,7 @@ extern "C" {
 #include <oauth.h>
 }
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "stream.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp Fri Dec 23 08:18:38 2011
@@ -25,6 +25,7 @@
 
 #include <sys/stat.h>
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "stream.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/modules/python/mod-python.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/python/mod-python.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/python/mod-python.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/python/mod-python.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * HTTPD module used to eval Python component implementations.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/modules/server/mod-eval.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/mod-eval.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/mod-eval.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/mod-eval.cpp Fri Dec 23 08:18:38 2011
@@ -23,6 +23,7 @@
  * HTTPD module used to eval C++ and Scheme component implementations.
  */
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "function.hpp"
 #include "list.hpp"

Modified: tuscany/sca-cpp/trunk/modules/server/mod-wiring.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/mod-wiring.cpp?rev=1222604&r1=1222603&r2=1222604&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/mod-wiring.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/mod-wiring.cpp Fri Dec 23 08:18:38 2011
@@ -26,6 +26,7 @@
 
 #include <sys/stat.h>
 
+#define WANT_HTTPD_LOG 1
 #include "string.hpp"
 #include "stream.hpp"
 #include "list.hpp"



Mime
View raw message