Disambiguate enable_syslog functions by adding a enable_syslog_facility enable-syslog-facility
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 22 Dec 2016 16:54:19 +0000 (17:54 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Thu, 23 Mar 2017 10:43:34 +0000 (11:43 +0100)
Had determined that compiler casts Facility to bool even if given the perfect
constant value; avoid this by renaming one of the functions.

Also made arguments const refs (but that was not enough)

src/logfunc.cpp
src/logfunc.hpp
test/test_logging.cpp

index c6883fc..2a751c8 100644 (file)
@@ -618,7 +618,7 @@ PartLogger::LogHelper PartLogger::debug(const SourceLocation& loc)
  * @param name the name used as ident.
  * @param facility the facility which should be used.
  */
-void enable_syslog( const std::string& name, Facility facility )
+void enable_syslog( const std::string& name, const Facility &facility )
 {
     boost::recursive_mutex::scoped_lock lock(LoggerLock);
 
@@ -635,7 +635,7 @@ void enable_syslog( const std::string& name, Facility facility )
  * determined by reading the program path from /proc/\<pid\>/exe.
  * @param facility the facility which should be used.
  */
-void enable_syslog( Facility facility )
+void enable_syslog_facility( const Facility &facility )
 {
     boost::recursive_mutex::scoped_lock lock(LoggerLock);
 
@@ -653,7 +653,7 @@ void enable_syslog( Facility facility )
  * enable or disable logging to syslog.
  * @param enable whether the logging to syslog should be enabled or not.
  */
-void enable_syslog( bool enable )
+void enable_syslog( const bool enable )
 {
     boost::recursive_mutex::scoped_lock lock(LoggerLock);
 
@@ -661,7 +661,7 @@ void enable_syslog( bool enable )
     {
         if (!g_syslog_opened)
         {
-            enable_syslog( g_facility );
+            enable_syslog_facility( g_facility );
         }
     }
     else // ! enable
index 56b1814..849e700 100644 (file)
@@ -194,9 +194,9 @@ extern PartLogger GlobalLogger;
 ** They work globally; i.e. they determine the loggin for the whole program!
 */
 
-void enable_syslog( const std::string& name, Facility facility= Facility::User );
-void enable_syslog( Facility facility );
-void enable_syslog( bool enable= true );
+void enable_syslog( const std::string& name, const Facility &facility= Facility::User );
+void enable_syslog_facility( const Facility &facility );  // avoid compiler casting facility to bool
+void enable_syslog( const bool enable= true );
 
 void enable_stderr_log(bool enable= true );
 
index 597e82b..623551b 100644 (file)
@@ -79,7 +79,7 @@ BOOST_FIXTURE_TEST_SUITE(TestLogging, TestLoggingFixture)
 BOOST_AUTO_TEST_CASE(Syslog1)
 {
     //Logger::enable_syslog("I2N Unittest", Logger::Facility::User );
-    Logger::enable_syslog( Logger::Facility::User );
+    Logger::enable_syslog_facility( Logger::Facility::User );
     Logger::PartLogger log(__func__);
 
     Logger::set_log_level( 7 );
@@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE(Syslog1)
 BOOST_AUTO_TEST_CASE(TestScopeTrace1)
 {
     //Logger::enable_syslog("I2N Unittest", Logger::Facility::User );
-    Logger::enable_syslog( Logger::Facility::User );
+    Logger::enable_syslog_facility( Logger::Facility::User );
     Logger::PartLogger log(__func__);
 
     Logger::set_log_level( 7 );
@@ -141,7 +141,7 @@ void recursive_function(int level=0)
 
 BOOST_AUTO_TEST_CASE(TestRecursiveScopeTracker)
 {
-    Logger::enable_syslog( Logger::Facility::User );
+    Logger::enable_syslog_facility( Logger::Facility::User );
     Logger::PartLogger log(__func__);
 
     Logger::set_log_level( 7 );