Do not use ostringstream if not really needed.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Thu, 17 Sep 2009 14:43:19 +0000 (16:43 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Thu, 17 Sep 2009 14:43:19 +0000 (16:43 +0200)
src/logger.cpp

index dc712e9..4f9ce3c 100644 (file)
@@ -188,9 +188,7 @@ void Logger::print_cmd_parsed() const
     int level = 1;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Command line options successfully parsed." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Command line options successfully parsed.",level);
     }
 }
 
@@ -200,9 +198,7 @@ void Logger::print_conf_files_parsed() const
     int level = 1;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Config files successfully parsed." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Config files successfully parsed.",level);
     }
 }
 
@@ -439,9 +435,7 @@ void Logger::print_missing_cmd_service_option() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Missing option to initialize service. Protocol, host, login and password must be specified." << endl;
-        log_error(msg.str(),level);
+        log_error("Missing option to initialize service. Protocol, host, login and password must be specified.",level);
     }
 }
 
@@ -505,9 +499,7 @@ void Logger::print_error_fork() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Error while trying to fork." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Error while trying to fork.",level);
     }
 }
 
@@ -552,9 +544,7 @@ void Logger::print_caught_sigterm() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Caught SIGTERM. Exiting..." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Caught SIGTERM. Exiting...",level);
     }
 }
 
@@ -567,9 +557,7 @@ void Logger::print_caught_siguser1() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Caught SIGUSR1. Switching to offline mode..." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Caught SIGUSR1. Switching to offline mode...",level);
     }
 }
 
@@ -582,9 +570,7 @@ void Logger::print_caught_sighup() const
     int level = 1;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Caught SIGHUP. Reloading config and switching to online mode..." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Caught SIGHUP. Reloading config and switching to online mode...",level);
     }
 }
 
@@ -627,9 +613,7 @@ void Logger::print_offline_mode() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Offline mode..." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Offline mode...",level);
     }
 }
 
@@ -642,9 +626,7 @@ void Logger::print_serialized_objects_success() const
     int level = 1;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Serialized objects successfully." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Serialized objects successfully.",level);
     }
 }
 
@@ -657,9 +639,7 @@ void Logger::print_deserialized_objects_success() const
     int level = 1;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "De-serialized objects successfully." << endl;
-        log_notice(msg.str(),level);
+        log_notice("De-serialized objects successfully.",level);
     }
 }
 
@@ -867,9 +847,7 @@ void Logger::print_webcheck_no_ip() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "IP-Address of this host could not be determined through any configured webcheck url." << endl;
-        log_warning(msg.str(),level);
+        log_warning("IP-Address of this host could not be determined through any configured webcheck url.",level);
     }
 }
 
@@ -1015,9 +993,7 @@ void Logger::print_starting_shutdown() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Shutting down ..." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Shutting down ...",level);
     }
 }
 
@@ -1030,9 +1006,7 @@ void Logger::print_shutdown_succeeded() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Shutting down complete ..." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Shutting down complete ...",level);
     }
 }
 
@@ -1045,9 +1019,7 @@ void Logger::print_shutdown_parent_succeeded() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Shutting down parent process completed ..." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Shutting down parent process completed ...",level);
     }
 }
 
@@ -1060,9 +1032,7 @@ void Logger::print_starting_shutdown_parent() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Shutting down parent process ..." << endl;
-        log_notice(msg.str(),level);
+        log_notice("Shutting down parent process ...",level);
     }
 }
 
@@ -1111,9 +1081,7 @@ void Logger::print_missing_cmd_proxy_option() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Missing option to initialize proxy. http_proxy and http_proxy_port must be specified." << endl;
-        log_error(msg.str(),level);
+        log_error("Missing option to initialize proxy. http_proxy and http_proxy_port must be specified.",level);
     }
 }
 
@@ -1415,9 +1383,7 @@ void Logger::print_could_not_get_initial_gnudip_data() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Could not get salt, time and sign from map." << endl;
-        log_warning(msg.str(),level);
+        log_warning("Could not get salt, time and sign from map.",level);
     }
 }
 
@@ -1431,9 +1397,7 @@ void Logger::print_gnudip_requires_servername() const
     int level = 0;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
-        ostringstream msg;
-        msg << "Gnudip requires explicit definition of servername via config!" << endl;
-        log_warning(msg.str(),level);
+        log_warning("Gnudip requires explicit definition of servername via config!",level);
     }
 }