From d59fdfce0fb7822f55cd39cdf5f3c55e92e2a53f Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Wed, 30 Nov 2011 03:46:48 +0000 Subject: Enable log collection using Scribe, and some minor log cleanup. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1208240 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/.gitignore | 1 + sca-cpp/trunk/components/cache/datacache.cpp | 2 +- sca-cpp/trunk/components/cache/memcache.hpp | 2 +- sca-cpp/trunk/kernel/monad.hpp | 26 ++++++----- sca-cpp/trunk/modules/edit/ssl-start | 66 +++++++++++++++++++++++----- sca-cpp/trunk/modules/edit/start | 39 +++++++++++++--- sca-cpp/trunk/modules/edit/stop | 6 +++ sca-cpp/trunk/modules/http/httpd-conf | 15 +++++-- sca-cpp/trunk/modules/http/httpd-ssl-conf | 10 ++++- sca-cpp/trunk/modules/http/mod-security-conf | 13 ++++-- sca-cpp/trunk/modules/server/mod-eval.hpp | 2 +- 11 files changed, 143 insertions(+), 39 deletions(-) (limited to 'sca-cpp') diff --git a/sca-cpp/trunk/.gitignore b/sca-cpp/trunk/.gitignore index 1dd44f8fd9..d1d2818389 100644 --- a/sca-cpp/trunk/.gitignore +++ b/sca-cpp/trunk/.gitignore @@ -136,6 +136,7 @@ js-test js-eval file-test test-start* +test-stop* xml-value value-xml json-value diff --git a/sca-cpp/trunk/components/cache/datacache.cpp b/sca-cpp/trunk/components/cache/datacache.cpp index 502a57671d..994aa4840e 100644 --- a/sca-cpp/trunk/components/cache/datacache.cpp +++ b/sca-cpp/trunk/components/cache/datacache.cpp @@ -55,7 +55,7 @@ const failable get(const value& key, const lambda if (isNil(val2)) { ostringstream os; os << "Couldn't get cache entry: " << key; - return mkfailure(str(os)); + return mkfailure(str(os), false); } // Update level1 cache diff --git a/sca-cpp/trunk/components/cache/memcache.hpp b/sca-cpp/trunk/components/cache/memcache.hpp index 5d23ff7c42..f19f18c4ec 100644 --- a/sca-cpp/trunk/components/cache/memcache.hpp +++ b/sca-cpp/trunk/components/cache/memcache.hpp @@ -180,7 +180,7 @@ const failable get(const value& key, const MemCached& cache) { if (rc != APR_SUCCESS) { ostringstream os; os << "Couldn't get memcached entry: " << key; - return mkfailure(str(os)); + return mkfailure(str(os), false); } const value val(scheme::readValue(string(data, size))); diff --git a/sca-cpp/trunk/kernel/monad.hpp b/sca-cpp/trunk/kernel/monad.hpp index 34e39c72d9..c21f6409b7 100644 --- a/sca-cpp/trunk/kernel/monad.hpp +++ b/sca-cpp/trunk/kernel/monad.hpp @@ -242,7 +242,7 @@ private: template friend const bool hasContent(const failable& m); template friend const A content(const failable& m); template friend const B reason(const failable& m); - template friend const failable mkfailure(const B& f); + template friend const failable mkfailure(const B& f, const bool log = true); template friend const failable mkfailure(); bool hasv; @@ -276,22 +276,26 @@ template const lambda(const V)> success() /** * Returns a failable monad with a failure in it. */ -template const failable mkfailure(const F& f) { +template const failable mkfailure(const F& f, const bool log = true) { #ifdef WANT_MAINTAINER_MODE - ostringstream os; - os << f; - if (length(str(os)) != 0) - debug(f, "failable::mkfailure"); + if (log) { + ostringstream os; + os << f; + if (length(str(os)) != 0) + debug(f, "failable::mkfailure"); + } #else - ostringstream os; - os << f; - if (length(str(os)) != 0) - cfailure << "failable::mkfailure" << ": " << f << endl; + if (log) { + ostringstream os; + os << f; + if (length(str(os)) != 0) + cfailure << "failable::mkfailure" << ": " << f << endl; + } #endif return failable(false, f); } -template const failable mkfailure(const char* f) { +template const failable mkfailure(const char* f, const bool log = true) { return mkfailure(string(f)); } diff --git a/sca-cpp/trunk/modules/edit/ssl-start b/sca-cpp/trunk/modules/edit/ssl-start index 5103566a5c..015a5dda66 100755 --- a/sca-cpp/trunk/modules/edit/ssl-start +++ b/sca-cpp/trunk/modules/edit/ssl-start @@ -27,6 +27,18 @@ jsprefix=`echo "import os; print os.path.realpath('$here/../js')" | python` ../../modules/http/ssl-ca-conf tmp sca-store.com ../../modules/http/ssl-cert-conf tmp sca-store.com server +# Configure and start logging +if [ -x ../../components/log/scribe-cat ]; then + ../../components/log/scribed-central-conf tmp + ../../components/log/scribed-client-conf tmp localhost + ../../components/log/scribed-central-start tmp + ../../components/log/scribed-client-start tmp +fi + +# Start memcached +../../components/cache/memcached-start 11211 +../../components/cache/memcached-start 11212 + # Configure server ../../modules/http/httpd-conf tmp sca-store.com 8090 htdocs ../../modules/http/httpd-event-conf tmp @@ -41,21 +53,21 @@ jsprefix=`echo "import os; print os.path.realpath('$here/../js')" | python` # Configure OAuth authentication # Configure your OAuth app keys here ../../modules/oauth/oauth-conf tmp -../../modules/oauth/oauth-memcached-conf tmp sca-store.com 11212 +../../modules/oauth/oauth-memcached-conf tmp localhost 11212 ../../modules/oauth/oauth2-appkey-conf tmp facebook.com 12345 67890 # Configure OpenID step2 authentication ../../modules/openid/openid-conf tmp ../../modules/openid/openid-step2-conf tmp -../../modules/openid/openid-memcached-conf tmp sca-store.com 11212 +../../modules/openid/openid-memcached-conf tmp localhost 11212 # Configure authorized users #../../modules/http/group-auth-conf tmp john #../../modules/http/group-auth-conf tmp jane #../../modules/http/group-auth-conf tmp admin -# Configure your OpenID and OAuth ids here -../../modules/http/group-auth-conf tmp https://www.google.com/accounts/o8/id?id=45678 -../../modules/http/group-auth-conf tmp 23456789 +# Configure the email addresses associated with your OpenID and OAuth ids here +../../modules/http/group-auth-conf tmp john@sca-store.com +../../modules/http/group-auth-conf tmp jane@sca-store.com # Configure mod-security ../../modules/http/mod-security-conf tmp @@ -64,8 +76,42 @@ jsprefix=`echo "import os; print os.path.realpath('$here/../js')" | python` ../../modules/server/server-conf tmp ../../modules/python/python-conf tmp +# Configure server log streaming +if [ -x ../../components/log/scribe-cat ]; then + cat >tmp/conf/log.conf <tmp/conf/log-ssl.conf <tmp/conf/mod-security-log.conf <>tmp/conf/svhost-ssl.conf < +ForceType application/x-x509-ca-cert + + +EOF + # Configure error pages cat >>tmp/conf/svhost-ssl.conf <>tmp/conf/httpd.conf <>tmp/conf/httpd.conf <>tmp/conf/svhost-ssl.conf < RewriteEngine on @@ -119,10 +165,6 @@ EOF # Create application database directories mkdir -p tmp/appdata/filedb -# Start memcached -../../components/cache/memcached-start 11211 -../../components/cache/memcached-start 11212 - # Start server ../../modules/http/httpd-start tmp diff --git a/sca-cpp/trunk/modules/edit/start b/sca-cpp/trunk/modules/edit/start index 361cead2df..c3ef1f7c4d 100755 --- a/sca-cpp/trunk/modules/edit/start +++ b/sca-cpp/trunk/modules/edit/start @@ -23,6 +23,18 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` jsprefix=`echo "import os; print os.path.realpath('$here/../js')" | python` +# Configure and start logging +if [ -x ../../components/log/scribe-cat ]; then + ../../components/log/scribed-central-conf tmp + ../../components/log/scribed-client-conf tmp localhost + ../../components/log/scribed-central-start tmp + ../../components/log/scribed-client-start tmp +fi + +# Start memcached +../../components/cache/memcached-start 11211 +../../components/cache/memcached-start 11212 + # Configure server ../../modules/http/httpd-conf tmp sca-store.com 8090 htdocs ../../modules/http/httpd-event-conf tmp @@ -31,8 +43,26 @@ jsprefix=`echo "import os; print os.path.realpath('$here/../js')" | python` ../server/server-conf tmp ../python/python-conf tmp +# Configure server log streaming +if [ -x ../../components/log/scribe-cat ]; then + cat >tmp/conf/log.conf <tmp/conf/log-ssl.conf <>tmp/conf/svhost.conf <>tmp/conf/httpd.conf <>tmp/conf/httpd.conf <>tmp/conf/svhost.conf < RewriteEngine on @@ -85,10 +116,6 @@ EOF # Create application database directories mkdir -p tmp/appdata/filedb -# Start memcached -../../components/cache/memcached-start 11211 -../../components/cache/memcached-start 11212 - # Start server ../../modules/http/httpd-start tmp diff --git a/sca-cpp/trunk/modules/edit/stop b/sca-cpp/trunk/modules/edit/stop index 60c25f88f5..8e250de88b 100755 --- a/sca-cpp/trunk/modules/edit/stop +++ b/sca-cpp/trunk/modules/edit/stop @@ -18,6 +18,12 @@ # under the License. ../../modules/http/httpd-stop tmp + ../../components/cache/memcached-stop 11211 ../../components/cache/memcached-stop 11212 +if [ -x ../../components/log/scribe-cat ]; then + ../../components/log/scribed-client-stop tmp + ../../components/log/scribed-central-stop tmp +fi + diff --git a/sca-cpp/trunk/modules/http/httpd-conf b/sca-cpp/trunk/modules/http/httpd-conf index 9b55270bea..5d4e9f5485 100755 --- a/sca-cpp/trunk/modules/http/httpd-conf +++ b/sca-cpp/trunk/modules/http/httpd-conf @@ -82,9 +82,10 @@ HostNameLookups Off # status response-size "referrer" "user-agent" "user-track" local-IP # virtual-host response-time bytes-received bytes-sent LogLevel notice -ErrorLog $root/logs/error_log 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 -CustomLog $root/logs/access_log combined +Include conf/log.conf + +# Configure tracking CookieTracking on CookieName TuscanyVisitorId CookieStyle Cookie @@ -93,7 +94,7 @@ CookieExpires 31556926 # Configure Mime types and default charsets TypesConfig $here/conf/mime.types AddDefaultCharset utf-8 -AddCharset utf-8 .js .css +AddCharset utf-8 .html .js .css # Configure cache control SetEnvIf Request_URI "^/app.html$" must-revalidate @@ -183,6 +184,14 @@ Require all granted EOF +# Configure logging +cat >$root/conf/log.conf <$root/conf/mpm.conf <= 128 # "SSL-client-I-DN" "SSL-client-S-DN" "user-track" local-IP virtual-host # response-time bytes-received bytes-sent 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\" \"%{cookie}n\" %A %V %D %I %O" sslcombined -CustomLog $root/logs/ssl_access_log sslcombined +Include conf/log-ssl.conf # Enable HTTPS reverse proxy ProxyRequests Off @@ -154,6 +154,14 @@ SSLProxyCheckPeerCN Off EOF +# Configure logging +cat >$root/conf/log-ssl.conf <$root/conf/mod-security.conf <$root/conf/mod-security-log.conf < failableResult(const list& v) { if (isNil(cdr(v))) return car(v); - return mkfailure(string(cadr(v))); + return mkfailure(string(cadr(v)), false); } /** -- cgit v1.2.3