summaryrefslogtreecommitdiffstats
path: root/sca-cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-12-23 08:18:38 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-12-23 08:18:38 +0000
commit681567b28116421496c4b7560a5b70f9730b8a79 (patch)
tree527231756f6a291ba35a217e3cd880c2cf15e5e0 /sca-cpp
parentf55fe8a88efb11b57fcb393ce5958e5dcace24d7 (diff)
Use HTTPD ap_log_error instead of stderr to log when running inside HTTPD, to get log piping and rotation to work.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1222604 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/components/cache/datacache.cpp1
-rw-r--r--sca-cpp/trunk/components/cache/memcache.cpp1
-rw-r--r--sca-cpp/trunk/components/cache/memocache.cpp1
-rw-r--r--sca-cpp/trunk/components/chat/chat-sender.cpp1
-rw-r--r--sca-cpp/trunk/components/chat/chat-sender2.cpp1
-rw-r--r--sca-cpp/trunk/components/chat/chat-sendreceiver.cpp1
-rw-r--r--sca-cpp/trunk/components/constdb/constdb.cpp1
-rw-r--r--sca-cpp/trunk/components/filedb/filedb.cpp1
-rw-r--r--sca-cpp/trunk/components/http/httpdelete.cpp1
-rw-r--r--sca-cpp/trunk/components/http/httpget.cpp1
-rw-r--r--sca-cpp/trunk/components/http/httppatch.cpp1
-rw-r--r--sca-cpp/trunk/components/http/httppost.cpp1
-rw-r--r--sca-cpp/trunk/components/http/httpput.cpp1
-rw-r--r--sca-cpp/trunk/components/kvdb/kvdb.cpp1
-rw-r--r--sca-cpp/trunk/components/log/log.cpp1
-rw-r--r--sca-cpp/trunk/components/log/logger.cpp1
-rw-r--r--sca-cpp/trunk/components/log/scribe.hpp1
-rw-r--r--sca-cpp/trunk/components/queue/queue-listener.cpp1
-rw-r--r--sca-cpp/trunk/components/queue/queue-sender.cpp1
-rw-r--r--sca-cpp/trunk/components/sqldb/sqldb.cpp1
-rw-r--r--sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp1
-rw-r--r--sca-cpp/trunk/components/webservice/axis2-service.cpp1
-rw-r--r--sca-cpp/trunk/components/webservice/webservice-client.cpp1
-rw-r--r--sca-cpp/trunk/components/webservice/webservice-listener.cpp1
-rw-r--r--sca-cpp/trunk/kernel/fstream.hpp131
-rw-r--r--sca-cpp/trunk/kernel/monad.hpp11
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-conf2
-rw-r--r--sca-cpp/trunk/modules/http/httpd.hpp5
-rw-r--r--sca-cpp/trunk/modules/http/mod-openauth.cpp26
-rw-r--r--sca-cpp/trunk/modules/http/mod-ssltunnel.cpp1
-rw-r--r--sca-cpp/trunk/modules/java/mod-java.cpp1
-rw-r--r--sca-cpp/trunk/modules/js/eval.hpp7
-rw-r--r--sca-cpp/trunk/modules/oauth/mod-oauth1.cpp1
-rw-r--r--sca-cpp/trunk/modules/oauth/mod-oauth2.cpp1
-rw-r--r--sca-cpp/trunk/modules/python/mod-python.cpp1
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.cpp1
-rw-r--r--sca-cpp/trunk/modules/server/mod-wiring.cpp1
37 files changed, 172 insertions, 41 deletions
diff --git a/sca-cpp/trunk/components/cache/datacache.cpp b/sca-cpp/trunk/components/cache/datacache.cpp
index 994aa4840e..f7e812dd18 100644
--- a/sca-cpp/trunk/components/cache/datacache.cpp
+++ b/sca-cpp/trunk/components/cache/datacache.cpp
@@ -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"
diff --git a/sca-cpp/trunk/components/cache/memcache.cpp b/sca-cpp/trunk/components/cache/memcache.cpp
index 768bcffb67..7547ec65df 100644
--- a/sca-cpp/trunk/components/cache/memcache.cpp
+++ b/sca-cpp/trunk/components/cache/memcache.cpp
@@ -23,6 +23,7 @@
* Memcached-based cache component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/cache/memocache.cpp b/sca-cpp/trunk/components/cache/memocache.cpp
index 2482c2202b..054638e275 100644
--- a/sca-cpp/trunk/components/cache/memocache.cpp
+++ b/sca-cpp/trunk/components/cache/memocache.cpp
@@ -29,6 +29,7 @@
* cache without actually applying the function.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/chat/chat-sender.cpp b/sca-cpp/trunk/components/chat/chat-sender.cpp
index d3726a4e1c..5e289d7eac 100644
--- a/sca-cpp/trunk/components/chat/chat-sender.cpp
+++ b/sca-cpp/trunk/components/chat/chat-sender.cpp
@@ -23,6 +23,7 @@
* XMPP chat sender component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/chat/chat-sender2.cpp b/sca-cpp/trunk/components/chat/chat-sender2.cpp
index 2224f64542..05dec36270 100644
--- a/sca-cpp/trunk/components/chat/chat-sender2.cpp
+++ b/sca-cpp/trunk/components/chat/chat-sender2.cpp
@@ -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"
diff --git a/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp b/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp
index 610f3cc9cc..ddc12bb164 100644
--- a/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp
+++ b/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp
@@ -23,6 +23,7 @@
* XMPP chat sender/receiver component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/constdb/constdb.cpp b/sca-cpp/trunk/components/constdb/constdb.cpp
index c76206b550..94df433a67 100644
--- a/sca-cpp/trunk/components/constdb/constdb.cpp
+++ b/sca-cpp/trunk/components/constdb/constdb.cpp
@@ -23,6 +23,7 @@
* TinyCDB-based database component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/filedb/filedb.cpp b/sca-cpp/trunk/components/filedb/filedb.cpp
index 5f755de3eb..ac4c3faa6b 100644
--- a/sca-cpp/trunk/components/filedb/filedb.cpp
+++ b/sca-cpp/trunk/components/filedb/filedb.cpp
@@ -23,6 +23,7 @@
* File based database component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/http/httpdelete.cpp b/sca-cpp/trunk/components/http/httpdelete.cpp
index 5f3f8ead11..109049f75d 100644
--- a/sca-cpp/trunk/components/http/httpdelete.cpp
+++ b/sca-cpp/trunk/components/http/httpdelete.cpp
@@ -23,6 +23,7 @@
* HTTP client component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/http/httpget.cpp b/sca-cpp/trunk/components/http/httpget.cpp
index fc89784749..59dc231209 100644
--- a/sca-cpp/trunk/components/http/httpget.cpp
+++ b/sca-cpp/trunk/components/http/httpget.cpp
@@ -23,6 +23,7 @@
* HTTP client component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/http/httppatch.cpp b/sca-cpp/trunk/components/http/httppatch.cpp
index ef72537185..06810e5d90 100644
--- a/sca-cpp/trunk/components/http/httppatch.cpp
+++ b/sca-cpp/trunk/components/http/httppatch.cpp
@@ -23,6 +23,7 @@
* HTTP client component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/http/httppost.cpp b/sca-cpp/trunk/components/http/httppost.cpp
index 0879ad2e59..f4b85710bb 100644
--- a/sca-cpp/trunk/components/http/httppost.cpp
+++ b/sca-cpp/trunk/components/http/httppost.cpp
@@ -23,6 +23,7 @@
* HTTP client component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/http/httpput.cpp b/sca-cpp/trunk/components/http/httpput.cpp
index 1eef0bef48..448456652b 100644
--- a/sca-cpp/trunk/components/http/httpput.cpp
+++ b/sca-cpp/trunk/components/http/httpput.cpp
@@ -23,6 +23,7 @@
* HTTP client component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/kvdb/kvdb.cpp b/sca-cpp/trunk/components/kvdb/kvdb.cpp
index 70ae1eda74..bab4e5d82b 100644
--- a/sca-cpp/trunk/components/kvdb/kvdb.cpp
+++ b/sca-cpp/trunk/components/kvdb/kvdb.cpp
@@ -23,6 +23,7 @@
* LevelDB-based database component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/log/log.cpp b/sca-cpp/trunk/components/log/log.cpp
index 24a5844c45..d43833680d 100644
--- a/sca-cpp/trunk/components/log/log.cpp
+++ b/sca-cpp/trunk/components/log/log.cpp
@@ -23,6 +23,7 @@
* Scribe-based log component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/log/logger.cpp b/sca-cpp/trunk/components/log/logger.cpp
index e1f4712d61..eb18ed30db 100644
--- a/sca-cpp/trunk/components/log/logger.cpp
+++ b/sca-cpp/trunk/components/log/logger.cpp
@@ -24,6 +24,7 @@
* and log service invocations.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/log/scribe.hpp b/sca-cpp/trunk/components/log/scribe.hpp
index 1e0ce46511..a7fecf9865 100644
--- a/sca-cpp/trunk/components/log/scribe.hpp
+++ b/sca-cpp/trunk/components/log/scribe.hpp
@@ -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
diff --git a/sca-cpp/trunk/components/queue/queue-listener.cpp b/sca-cpp/trunk/components/queue/queue-listener.cpp
index d714101583..394d462839 100644
--- a/sca-cpp/trunk/components/queue/queue-listener.cpp
+++ b/sca-cpp/trunk/components/queue/queue-listener.cpp
@@ -23,6 +23,7 @@
* AMQP queue listener component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/queue/queue-sender.cpp b/sca-cpp/trunk/components/queue/queue-sender.cpp
index 07f8491f54..1d5978e9a6 100644
--- a/sca-cpp/trunk/components/queue/queue-sender.cpp
+++ b/sca-cpp/trunk/components/queue/queue-sender.cpp
@@ -23,6 +23,7 @@
* AMQP queue sender component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/sqldb/sqldb.cpp b/sca-cpp/trunk/components/sqldb/sqldb.cpp
index fa82c0ee9f..c2b178f13e 100644
--- a/sca-cpp/trunk/components/sqldb/sqldb.cpp
+++ b/sca-cpp/trunk/components/sqldb/sqldb.cpp
@@ -23,6 +23,7 @@
* PostgreSQL-based database component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp b/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp
index 3f753e0e35..dafa6fd229 100644
--- a/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp
+++ b/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp
@@ -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 {
diff --git a/sca-cpp/trunk/components/webservice/axis2-service.cpp b/sca-cpp/trunk/components/webservice/axis2-service.cpp
index 4c0ce22722..498f3aea92 100644
--- a/sca-cpp/trunk/components/webservice/axis2-service.cpp
+++ b/sca-cpp/trunk/components/webservice/axis2-service.cpp
@@ -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"
diff --git a/sca-cpp/trunk/components/webservice/webservice-client.cpp b/sca-cpp/trunk/components/webservice/webservice-client.cpp
index 06db6c01b8..76d4905bf8 100644
--- a/sca-cpp/trunk/components/webservice/webservice-client.cpp
+++ b/sca-cpp/trunk/components/webservice/webservice-client.cpp
@@ -23,6 +23,7 @@
* Web service client component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/components/webservice/webservice-listener.cpp b/sca-cpp/trunk/components/webservice/webservice-listener.cpp
index 2127ecf0df..78a0ea9580 100644
--- a/sca-cpp/trunk/components/webservice/webservice-listener.cpp
+++ b/sca-cpp/trunk/components/webservice/webservice-listener.cpp
@@ -23,6 +23,7 @@
* Web service listener component implementation.
*/
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/kernel/fstream.hpp b/sca-cpp/trunk/kernel/fstream.hpp
index 89d1909f15..fe95fc02e0 100644
--- a/sca-cpp/trunk/kernel/fstream.hpp
+++ b/sca-cpp/trunk/kernel/fstream.hpp
@@ -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;
diff --git a/sca-cpp/trunk/kernel/monad.hpp b/sca-cpp/trunk/kernel/monad.hpp
index c16e7bade2..2ae49308a9 100644
--- a/sca-cpp/trunk/kernel/monad.hpp
+++ b/sca-cpp/trunk/kernel/monad.hpp
@@ -278,20 +278,15 @@ template<typename V, typename F> const lambda<failable<V, F>(const V)> success()
*/
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);
}
diff --git a/sca-cpp/trunk/modules/http/httpd-conf b/sca-cpp/trunk/modules/http/httpd-conf
index 50134410a9..5bcde9f633 100755
--- a/sca-cpp/trunk/modules/http/httpd-conf
+++ b/sca-cpp/trunk/modules/http/httpd-conf
@@ -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
diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp
index 06d53e28c2..f4e3767881 100644
--- a/sca-cpp/trunk/modules/http/httpd.hpp
+++ b/sca-cpp/trunk/modules/http/httpd.hpp
@@ -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 char* key, const char* value) {
* 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* key, const char* value) {
* 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* key, const char* value) {
* 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;
diff --git a/sca-cpp/trunk/modules/http/mod-openauth.cpp b/sca-cpp/trunk/modules/http/mod-openauth.cpp
index c2791b5402..09d62bf5f7 100644
--- a/sca-cpp/trunk/modules/http/mod-openauth.cpp
+++ b/sca-cpp/trunk/modules/http/mod-openauth.cpp
@@ -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> userInfoFromSession(const string& realm, request_rec* r) {
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));
}
}
diff --git a/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp b/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp
index 521b86626d..49ce6bbe52 100644
--- a/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp
+++ b/sca-cpp/trunk/modules/http/mod-ssltunnel.cpp
@@ -25,6 +25,7 @@
#include <sys/stat.h>
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "stream.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/modules/java/mod-java.cpp b/sca-cpp/trunk/modules/java/mod-java.cpp
index 510f9574b0..8c25f6f8ef 100644
--- a/sca-cpp/trunk/modules/java/mod-java.cpp
+++ b/sca-cpp/trunk/modules/java/mod-java.cpp
@@ -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"
diff --git a/sca-cpp/trunk/modules/js/eval.hpp b/sca-cpp/trunk/modules/js/eval.hpp
index 817ef7e086..17f73f2b43 100644
--- a/sca-cpp/trunk/modules/js/eval.hpp
+++ b/sca-cpp/trunk/modules/js/eval.hpp
@@ -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>") << ":"
- << (int)report->lineno << ":" << message << endl;
-#else
- cerr << (const char*)(report->filename? report->filename : "<no filename>") << ":"
+ cfailure << (const char*)(report->filename? report->filename : "<no filename>") << ":"
<< (int)report->lineno << ":" << message << endl;
-#endif
}
/**
diff --git a/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp b/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
index 94e9698d70..833dfc96c5 100644
--- a/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
+++ b/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp
@@ -30,6 +30,7 @@ extern "C" {
#include <oauth.h>
}
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "stream.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp b/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
index 0c49be879e..e8c27a5709 100644
--- a/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
+++ b/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp
@@ -25,6 +25,7 @@
#include <sys/stat.h>
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "stream.hpp"
#include "list.hpp"
diff --git a/sca-cpp/trunk/modules/python/mod-python.cpp b/sca-cpp/trunk/modules/python/mod-python.cpp
index f4d2febf10..89a2db1b33 100644
--- a/sca-cpp/trunk/modules/python/mod-python.cpp
+++ b/sca-cpp/trunk/modules/python/mod-python.cpp
@@ -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"
diff --git a/sca-cpp/trunk/modules/server/mod-eval.cpp b/sca-cpp/trunk/modules/server/mod-eval.cpp
index a94ccf5bbe..fcc4981ec0 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.cpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.cpp
@@ -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"
diff --git a/sca-cpp/trunk/modules/server/mod-wiring.cpp b/sca-cpp/trunk/modules/server/mod-wiring.cpp
index c2380be6a3..0dd0529a42 100644
--- a/sca-cpp/trunk/modules/server/mod-wiring.cpp
+++ b/sca-cpp/trunk/modules/server/mod-wiring.cpp
@@ -26,6 +26,7 @@
#include <sys/stat.h>
+#define WANT_HTTPD_LOG 1
#include "string.hpp"
#include "stream.hpp"
#include "list.hpp"