[shibboleth-sp2] 79/100: Added default logging configuration for command line tools.

Ferenc Wágner wferi-guest at moszumanska.debian.org
Tue Jan 26 21:29:19 UTC 2016


This is an automated email from the git hooks/post-receive script.

wferi-guest pushed a commit to annotated tag 1.2.1
in repository shibboleth-sp2.

commit 792ed1a21b31708458950fe9e0655e735b293c8c
Author: Scott Cantor <cantor.2 at osu.edu>
Date:   Tue Oct 26 20:15:10 2004 +0000

    Added default logging configuration for command line tools.
---
 shib-target/internal.h      |  4 ++++
 shib-target/shib-config.cpp | 28 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/shib-target/internal.h b/shib-target/internal.h
index 0910218..9b33bc7 100644
--- a/shib-target/internal.h
+++ b/shib-target/internal.h
@@ -79,6 +79,10 @@
 #define SHIBT_L_QNAME(p,s) shibtarget::XML::Literals::p##_##s
 #define SHIBTRAN_LOGCAT "Shibboleth-TRANSACTION"
 
+// Controls default logging level of console tools and other situations
+// where full shibboleth.xml-based logging isn't used.
+#define SHIB_LOGGING "WARN"
+
 namespace shibtarget {
 
     // Wraps the actual RPC connection
diff --git a/shib-target/shib-config.cpp b/shib-target/shib-config.cpp
index 9a0e17a..54e51a7 100644
--- a/shib-target/shib-config.cpp
+++ b/shib-target/shib-config.cpp
@@ -57,6 +57,8 @@
 
 #include "internal.h"
 
+#include <log4cpp/OstreamAppender.hh>
+
 using namespace std;
 using namespace log4cpp;
 using namespace saml;
@@ -92,6 +94,32 @@ ShibTargetConfig& ShibTargetConfig::getConfig()
 
 bool STConfig::init(const char* schemadir, const char* config)
 {
+    // With new build of log4cpp, we need to establish a "default"
+    // logging appender to stderr up front.
+    const char* loglevel=getenv("SHIB_LOGGING");
+    if (!loglevel)
+        loglevel = SHIB_LOGGING;    
+    Category& root = Category::getRoot();
+    if (!strcmp(loglevel,"DEBUG"))
+        root.setPriority(Priority::DEBUG);
+    else if (!strcmp(loglevel,"INFO"))
+        root.setPriority(Priority::INFO);
+    else if (!strcmp(loglevel,"NOTICE"))
+        root.setPriority(Priority::NOTICE);
+    else if (!strcmp(loglevel,"WARN"))
+        root.setPriority(Priority::WARN);
+    else if (!strcmp(loglevel,"ERROR"))
+        root.setPriority(Priority::ERROR);
+    else if (!strcmp(loglevel,"CRIT"))
+        root.setPriority(Priority::CRIT);
+    else if (!strcmp(loglevel,"ALERT"))
+        root.setPriority(Priority::ALERT);
+    else if (!strcmp(loglevel,"EMERG"))
+        root.setPriority(Priority::EMERG);
+    else if (!strcmp(loglevel,"FATAL"))
+        root.setPriority(Priority::FATAL);
+    root.setAppender(new OstreamAppender("default",&cerr));
+ 
     saml::NDC ndc("init");
     Category& log = Category::getInstance("shibtarget.STConfig");
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/shibboleth-sp2.git



More information about the Pkg-shibboleth-devel mailing list