[cpp-sp] branch main updated: Add CLI option to default console logging.

Scott Cantor cantor.2 at osu.edu
Thu Jan 16 14:33:16 UTC 2025


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

scantor pushed a commit to branch main
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=f5dafcec5e64e4ea4c443ed821435efac79f7780

The following commit(s) were added to refs/heads/main by this push:
     new f5dafcec Add CLI option to default console logging.
f5dafcec is described below

commit f5dafcec5e64e4ea4c443ed821435efac79f7780
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jan 16 09:33:12 2025 -0500

    Add CLI option to default console logging.
---
 shibsp/AgentConfig.h        |  7 +++++++
 shibsp/impl/AgentConfig.cpp | 22 +++++++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/shibsp/AgentConfig.h b/shibsp/AgentConfig.h
index ca0fa675..22e1d6a4 100644
--- a/shibsp/AgentConfig.h
+++ b/shibsp/AgentConfig.h
@@ -61,6 +61,13 @@ namespace shibsp {
          */
         static AgentConfig& getConfig();
 
+        /**
+         * Sets a flag indicating a command line program is initializing the agent.
+         * 
+         * <p>This can be used to adjust/affect default settings and plugin types used.</p>
+         */
+        virtual void setCommandLine(bool flag)=0;
+
         /**
          * Initializes agent/library.
          *
diff --git a/shibsp/impl/AgentConfig.cpp b/shibsp/impl/AgentConfig.cpp
index 6e1695fc..e074232d 100644
--- a/shibsp/impl/AgentConfig.cpp
+++ b/shibsp/impl/AgentConfig.cpp
@@ -59,9 +59,13 @@ namespace shibsp {
     class SHIBSP_DLLLOCAL AgentInternalConfig : public AgentConfig
     {
     public:
-        AgentInternalConfig() : m_initCount(0) {}
+        AgentInternalConfig() : m_initCount(0), m_cli(false) {}
         ~AgentInternalConfig() {}
 
+        void setCommandLine(bool flag) {
+            m_cli = flag;
+        }
+
         bool init(const char* inst_prefix=nullptr, const char* config_file=nullptr, bool rethrow=false);
         void term();
 
@@ -87,6 +91,7 @@ namespace shibsp {
         unsigned int m_initCount;
         mutex m_lock;
         ptree m_config;
+        bool m_cli;
         PathResolver m_pathResolver;
         URLEncoder m_urlEncoder;
         vector<void*> m_libhandles;
@@ -255,13 +260,20 @@ bool AgentInternalConfig::_init(const char* inst_prefix, const char* config_file
 bool AgentInternalConfig::initLogging()
 {
     // Config is loaded, look for logging section and type to instantiate.
-    string type = m_config.get(LoggingService::LOGGING_TYPE_PROP_PATH,
+    string type;
+    if (m_cli) {
+        type = CONSOLE_LOGGING_SERVICE;
+    }
+    else {
+        type = m_config.get(LoggingService::LOGGING_TYPE_PROP_PATH,
 #ifdef WIN32
-        WINDOWS_LOGGING_SERVICE
+            WINDOWS_LOGGING_SERVICE
 #else
-        SYSLOG_LOGGING_SERVICE
+            SYSLOG_LOGGING_SERVICE
 #endif
-        );
+            );
+    }
+    
     m_logging.reset(LoggingServiceManager.newPlugin(type, m_config, false));
     if (!m_logging->init()) {
         return false;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list