From 768a1e33e56c579edbcab1d4ea73d06b85cdd06c Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Thu, 19 Aug 2010 04:10:43 +0000 Subject: Script fixes to get database working with the HTTPS-enabled store-cluster sample configuration. Also some logging improvements and aggregation of the sample logs using scribe. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@987012 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/http/httpd-conf | 2 +- sca-cpp/trunk/modules/http/httpd-ssl-conf | 9 +++-- sca-cpp/trunk/modules/http/httpd.hpp | 54 +++++++++++++++++++---------- sca-cpp/trunk/modules/json/json.hpp | 4 ++- sca-cpp/trunk/modules/server/mod-eval.hpp | 6 ++-- sca-cpp/trunk/modules/server/mod-wiring.cpp | 2 +- 6 files changed, 50 insertions(+), 27 deletions(-) (limited to 'sca-cpp/trunk/modules') diff --git a/sca-cpp/trunk/modules/http/httpd-conf b/sca-cpp/trunk/modules/http/httpd-conf index 9f698688b1..4a094bbacf 100755 --- a/sca-cpp/trunk/modules/http/httpd-conf +++ b/sca-cpp/trunk/modules/http/httpd-conf @@ -92,7 +92,7 @@ HostNameLookups Off # Log HTTP requests LogLevel info ErrorLog $root/logs/error_log -LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined +LogFormat "[%{%a %b %d %H:%M:%S %Y}t] [access] %h %l %u \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined CustomLog $root/logs/access_log combined # Configure Mime types diff --git a/sca-cpp/trunk/modules/http/httpd-ssl-conf b/sca-cpp/trunk/modules/http/httpd-ssl-conf index da66733f9e..a6da987345 100755 --- a/sca-cpp/trunk/modules/http/httpd-ssl-conf +++ b/sca-cpp/trunk/modules/http/httpd-ssl-conf @@ -24,6 +24,9 @@ root=`readlink -f $1` conf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-conf"` host=`echo $conf | awk '{ print $6 }'` +gport=`echo $conf | awk '{ print $7 }'` +port=`$here/httpd-addr port $gport` +pport=`$here/httpd-addr pport $gport` sslpport=`$here/httpd-addr pport $2` ssllisten=`$here/httpd-addr listen $2` @@ -44,7 +47,8 @@ cat >>$root/conf/httpd.conf < RewriteEngine on -RewriteCond %{HTTPS} !^on$ +RewriteCond %{SERVER_PORT} ^$port$ [OR] +RewriteCond %{SERVER_PORT} ^$pport$ RewriteRule .* https://%{SERVER_NAME}:$sslpport%{REQUEST_URI} [R,L] @@ -99,8 +103,7 @@ SSLVerifyClient optional SSLVerifyDepth 1 # Log SSL requests -#CustomLog "$root/logs/ssl_request_log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" -LogFormat "%h %l %u %t %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{SSL_CLIENT_I_DN}x\" \"%{SSL_CLIENT_S_DN}x\"" sslcombined +LogFormat "[%{%a %b %d %H:%M:%S %Y}t] [sslaccess] %h %l %u %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{SSL_CLIENT_I_DN}x\" \"%{SSL_CLIENT_S_DN}x\"" sslcombined CustomLog $root/logs/ssl_access_log sslcombined EOF diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp index 767af11cf9..ef89cbda0a 100644 --- a/sca-cpp/trunk/modules/http/httpd.hpp +++ b/sca-cpp/trunk/modules/http/httpd.hpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,7 @@ #include "stream.hpp" #include "list.hpp" #include "value.hpp" +#include "monad.hpp" namespace tuscany { @@ -408,44 +410,60 @@ const void* userData(const string& k, const server_rec* s) { /** * Debug log. */ + +/** + * Log an optional value. + */ const char* debugOptional(const char* s) { if (s == NULL) return ""; return s; } +/** + * Log a header + */ int debugHeader(unused void* r, const char* key, const char* value) { - cerr << " header key: " << key << ", value: " << value << endl; + cdebug << " header key: " << key << ", value: " << value << endl; return 1; } +/** + * Log an environment variable + */ int debugEnv(unused void* r, const char* key, const char* value) { - cerr << " var key: " << key << ", value: " << value << endl; + cdebug << " var key: " << key << ", value: " << value << endl; return 1; } +/** + * Log a note. + */ int debugNote(unused void* r, const char* key, const char* value) { - cerr << " note key: " << key << ", value: " << value << endl; + cdebug << " note key: " << key << ", value: " << value << endl; return 1; } +/** + * Log a request. + */ const bool debugRequest(request_rec* r, const string& msg) { - cerr << msg << ":" << endl; - cerr << " server: " << debugOptional(r->server->server_hostname) << endl; - cerr << " protocol: " << debugOptional(r->protocol) << endl; - cerr << " method: " << debugOptional(r->method) << endl; - cerr << " method number: " << r->method_number << endl; - cerr << " content type: " << contentType(r) << endl; - cerr << " content encoding: " << debugOptional(r->content_encoding) << endl; + cdebug << msg << ":" << endl; + cdebug << " server: " << debugOptional(r->server->server_hostname) << endl; + cdebug << " protocol: " << debugOptional(r->protocol) << endl; + cdebug << " method: " << debugOptional(r->method) << endl; + cdebug << " method number: " << r->method_number << endl; + cdebug << " content type: " << contentType(r) << endl; + cdebug << " content encoding: " << debugOptional(r->content_encoding) << endl; apr_table_do(debugHeader, r, r->headers_in, NULL); - cerr << " unparsed uri: " << debugOptional(r->unparsed_uri) << endl; - cerr << " uri: " << debugOptional(r->uri) << endl; - cerr << " path info: " << debugOptional(r->path_info) << endl; - cerr << " filename: " << debugOptional(r->filename) << endl; - cerr << " uri tokens: " << pathTokens(r->uri) << endl; - cerr << " args: " << debugOptional(r->args) << endl; - cerr << " user: " << debugOptional(r->user) << endl; - cerr << " auth type: " << debugOptional(r->ap_auth_type) << endl; + cdebug << " unparsed uri: " << debugOptional(r->unparsed_uri) << endl; + cdebug << " uri: " << debugOptional(r->uri) << endl; + cdebug << " path info: " << debugOptional(r->path_info) << endl; + cdebug << " filename: " << debugOptional(r->filename) << endl; + cdebug << " uri tokens: " << pathTokens(r->uri) << endl; + cdebug << " args: " << debugOptional(r->args) << endl; + cdebug << " user: " << debugOptional(r->user) << endl; + cdebug << " auth type: " << debugOptional(r->ap_auth_type) << endl; apr_table_do(debugEnv, r, r->subprocess_env, NULL); apr_table_do(debugEnv, r, r->notes, NULL); return true; diff --git a/sca-cpp/trunk/modules/json/json.hpp b/sca-cpp/trunk/modules/json/json.hpp index 4e02cbf2c9..f904718f05 100644 --- a/sca-cpp/trunk/modules/json/json.hpp +++ b/sca-cpp/trunk/modules/json/json.hpp @@ -41,8 +41,10 @@ namespace json { * Report JSON errors. */ void reportError(unused JSContext *cx, const char *message, JSErrorReport *report) { - cerr << (const char*)(report->filename? report->filename : "") << ":" +#ifdef WANT_MAINTAINER_MODE + cdebug << (const char*)(report->filename? report->filename : "") << ":" << (int)report->lineno << ":" << message << endl; +#endif } /** diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp index 0d90cb7ceb..391f5b8325 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.hpp +++ b/sca-cpp/trunk/modules/server/mod-eval.hpp @@ -671,7 +671,7 @@ int postConfig(apr_pool_t *p, unused apr_pool_t *plog, unused apr_pool_t *ptemp, // Configure the deployed components const failable res = confComponents(sc); if (!hasContent(res)) { - cerr << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl; + cfailure << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl; return -1; } @@ -689,14 +689,14 @@ void childInit(apr_pool_t* p, server_rec* s) { gc_scoped_pool pool(p); ServerConf* sc = (ServerConf*)ap_get_module_config(s->module_config, &mod_tuscany_eval); if(sc == NULL) { - cerr << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl; + cfailure << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl; exit(APEXIT_CHILDFATAL); } // Start the components in the child process const failable res = startComponents(*sc); if (!hasContent(res)) { - cerr << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl; + cfailure << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl; exit(APEXIT_CHILDFATAL); } diff --git a/sca-cpp/trunk/modules/server/mod-wiring.cpp b/sca-cpp/trunk/modules/server/mod-wiring.cpp index 7ed47c7f48..32217172fd 100644 --- a/sca-cpp/trunk/modules/server/mod-wiring.cpp +++ b/sca-cpp/trunk/modules/server/mod-wiring.cpp @@ -396,7 +396,7 @@ void childInit(apr_pool_t* p, server_rec* s) { gc_scoped_pool pool(p); ServerConf *conf = (ServerConf*)ap_get_module_config(s->module_config, &mod_tuscany_wiring); if(conf == NULL) { - cerr << "[Tuscany] Due to one or more errors mod_tuscany_wiring loading failed. Causing apache to stop loading." << endl; + cfailure << "[Tuscany] Due to one or more errors mod_tuscany_wiring loading failed. Causing apache to stop loading." << endl; exit(APEXIT_CHILDFATAL); } } -- cgit v1.2.3