]> granicus.if.org Git - icinga2/commitdiff
Update some more log messages
authorGunnar Beutner <gunnar@beutner.name>
Mon, 20 Oct 2014 08:09:57 +0000 (10:09 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 20 Oct 2014 08:09:57 +0000 (10:09 +0200)
14 files changed:
lib/base/logger.cpp
lib/base/logger.hpp
lib/checker/checkercomponent.cpp
lib/db_ido/servicedbobject.cpp
lib/db_ido_mysql/idomysqlconnection.cpp
lib/demo/demo.cpp
lib/icinga/externalcommandprocessor.cpp
lib/livestatus/livestatuslogutility.cpp
lib/livestatus/logtable.cpp
lib/perfdata/graphitewriter.cpp
lib/remote/apiclient.cpp
lib/remote/apilistener-sync.cpp
lib/remote/apilistener.cpp
lib/remote/endpoint.cpp

index 2cee05d8b4c02fda0411c4f797f15dce07559a2e..85ec07f568f51967c53786092618913a40e53022 100644 (file)
@@ -173,7 +173,8 @@ LogSeverity Logger::StringToSeverity(const String& severity)
        else if (severity == "critical")
                return LogCritical;
        else {
-               Log(LogCritical, "Logger", "Invalid severity: '" + severity + "'.");
+               Log(LogCritical, "Logger")
+                   << "Invalid severity: '" << severity << "'.";
                BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid severity: " + severity));
        }
 }
index 514d6f0bad8996327bad49952c27d01fa85f77ca..cd4c313905b84f4f1bda2de47adc424e6a4982a2 100644 (file)
@@ -131,6 +131,9 @@ private:
        LogSeverity m_Severity;
        String m_Facility;
        std::ostringstream m_Buffer;
+
+       Log(void);
+       Log& operator=(const Log& rhs);
 };
 
 }
index 708d2422870a62555acdf1a141078097450c81b9..8b0eabae963377956bc23141790978bb26aa308e 100644 (file)
@@ -136,7 +136,8 @@ void CheckerComponent::CheckThreadProc(void)
 
                if (!forced) {
                        if (!checkable->IsReachable(DependencyCheckExecution)) {
-                               Log(LogNotice, "CheckerComponent", "Skipping check for object '" + checkable->GetName() + "': Dependency failed.");
+                               Log(LogNotice, "CheckerComponent")
+                                   << "Skipping check for object '" << checkable->GetName() << "': Dependency failed.";
                                check = false;
                        }
 
@@ -145,18 +146,21 @@ void CheckerComponent::CheckThreadProc(void)
                        tie(host, service) = GetHostService(checkable);
 
                        if (host && !service && (!checkable->GetEnableActiveChecks() || !IcingaApplication::GetInstance()->GetEnableHostChecks())) {
-                               Log(LogNotice, "CheckerComponent", "Skipping check for host '" + host->GetName() + "': active host checks are disabled");
+                               Log(LogNotice, "CheckerComponent")
+                                   << "Skipping check for host '" << host->GetName() << "': active host checks are disabled";
                                check = false;
                        }
                        if (host && service && (!checkable->GetEnableActiveChecks() || !IcingaApplication::GetInstance()->GetEnableServiceChecks())) {
-                               Log(LogNotice, "CheckerComponent", "Skipping check for service '" + service->GetName() + "': active service checks are disabled");
+                               Log(LogNotice, "CheckerComponent")
+                                   << "Skipping check for service '" << service->GetName() << "': active service checks are disabled";
                                check = false;
                        }
 
                        TimePeriod::Ptr tp = checkable->GetCheckPeriod();
 
                        if (tp && !tp->IsInside(Utility::GetTime())) {
-                               Log(LogNotice, "CheckerComponent", "Skipping check for object '" + checkable->GetName() + "': not in check_period");
+                               Log(LogNotice, "CheckerComponent")
+                                   << "Skipping check for object '" << checkable->GetName() << "': not in check_period";
                                check = false;
                        }
                }
@@ -182,7 +186,8 @@ void CheckerComponent::CheckThreadProc(void)
                        checkable->SetForceNextCheck(false);
                }
 
-               Log(LogDebug, "CheckerComponent", "Executing check for '" + checkable->GetName() + "'");
+               Log(LogDebug, "CheckerComponent")
+                   << "Executing check for '" << checkable->GetName() << "'";
 
                CheckerComponent::Ptr self = GetSelf();
                Utility::QueueAsyncCallback(boost::bind(&CheckerComponent::ExecuteCheckHelper, self, checkable));
@@ -231,7 +236,8 @@ void CheckerComponent::ExecuteCheckHelper(const Checkable::Ptr& checkable)
                }
        }
 
-       Log(LogDebug, "CheckerComponent", "Check finished for object '" + checkable->GetName() + "'");
+       Log(LogDebug, "CheckerComponent")
+           << "Check finished for object '" << checkable->GetName() << "'";
 }
 
 void CheckerComponent::ResultTimerHandler(void)
index d9229dd945c0fef73726739ae69ba28a28ff6efb..9a114fa71ac45925019a9708ece0bcfc7f9da034 100644 (file)
@@ -235,7 +235,8 @@ void ServiceDbObject::OnConfigUpdate(void)
                OnQuery(query_contact);
        }
 
-       Log(LogDebug, "ServiceDbObject", "service contactgroups: " + service->GetName());
+       Log(LogDebug, "ServiceDbObject")
+           << "service contactgroups: " << service->GetName();
 
        BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(service)) {
                Log(LogDebug, "ServiceDbObject")
index c67de4429a33149fe7f982bdf45d845638a2c377..86d01578bc7103db356a5535650b47fb896e3e63 100644 (file)
@@ -356,7 +356,8 @@ IdoMysqlResult IdoMysqlConnection::Query(const String& query)
 {
        AssertOnWorkQueue();
 
-       Log(LogDebug, "IdoMysqlConnection", "Query: " + query);
+       Log(LogDebug, "IdoMysqlConnection")
+           << "Query: " << query;
 
        if (mysql_query(&m_Connection, query.CStr()) != 0) {
                std::ostringstream msgbuf;
@@ -710,7 +711,8 @@ void IdoMysqlConnection::InternalExecuteQuery(const DbQuery& query, DbQueryType
 
        if (type == DbQueryInsert && query.Table == "notifications" && query.NotificationObject) { // FIXME remove hardcoded table name
                SetNotificationInsertID(query.NotificationObject, GetLastInsertID());
-               Log(LogDebug, "IdoMysqlConnection", "saving contactnotification notification_id=" + Convert::ToString(static_cast<long>(GetLastInsertID())));
+               Log(LogDebug, "IdoMysqlConnection")
+                   << "saving contactnotification notification_id=" << static_cast<long>(GetLastInsertID());
        }
 }
 
index 4d163a65b62d6b0b6b6c2b26e629042f9bf613d5..5a82138a7a288cd557697e0053e588bf8c8e324f 100644 (file)
@@ -59,7 +59,8 @@ void Demo::DemoTimerHandler(void)
 
 Value Demo::DemoMessageHandler(const MessageOrigin& origin, const Dictionary::Ptr&)
 {
-       Log(LogInformation, "Demo", "Got demo message from '" + origin.FromClient->GetEndpoint()->GetName() + "'");
+       Log(LogInformation, "Demo")
+           << "Got demo message from '" << origin.FromClient->GetEndpoint()->GetName() << "'";
 
        return Empty;
 }
index d938130fe0926528cd4c5ba5651a5110a72ff0a3..06b5acebe5003ce5d48128e2389bd21b0e53c892 100644 (file)
@@ -325,7 +325,9 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve
        result->SetExecutionEnd(time);
        result->SetActive(false);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Processing passive check result for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Processing passive check result for host '" << arguments[0] << "'";
+
        host->ProcessCheckResult(result);
 
        {
@@ -361,7 +363,9 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std:
        result->SetExecutionEnd(time);
        result->SetActive(false);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Processing passive check result for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Processing passive check result for service '" << arguments[1] << "'";
+
        service->ProcessCheckResult(result);
 
        {
@@ -384,12 +388,14 @@ void ExternalCommandProcessor::ScheduleHostCheck(double, const std::vector<Strin
        double planned_check = Convert::ToDouble(arguments[1]);
 
        if (planned_check > host->GetNextCheck()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Ignoring reschedule request for host '" +
-                   arguments[0] + "' (next check is already sooner than requested check time)");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Ignoring reschedule request for host '"
+                   << arguments[0] << "' (next check is already sooner than requested check time)";
                return;
        }
 
-       Log(LogNotice, "ExternalCommandProcessor", "Rescheduling next check for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Rescheduling next check for host '" << arguments[0] << "'";
 
        if (planned_check < Utility::GetTime())
                planned_check = Utility::GetTime();
@@ -408,7 +414,8 @@ void ExternalCommandProcessor::ScheduleForcedHostCheck(double, const std::vector
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced host check for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Rescheduling next check for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Rescheduling next check for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -428,12 +435,14 @@ void ExternalCommandProcessor::ScheduleSvcCheck(double, const std::vector<String
        double planned_check = Convert::ToDouble(arguments[2]);
 
        if (planned_check > service->GetNextCheck()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Ignoring reschedule request for service '" +
-                   arguments[1] + "' (next check is already sooner than requested check time)");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Ignoring reschedule request for service '"
+                   << arguments[1] << "' (next check is already sooner than requested check time)";
                return;
        }
 
-       Log(LogNotice, "ExternalCommandProcessor", "Rescheduling next check for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Rescheduling next check for service '" << arguments[1] << "'";
 
        if (planned_check < Utility::GetTime())
                planned_check = Utility::GetTime();
@@ -452,7 +461,8 @@ void ExternalCommandProcessor::ScheduleForcedSvcCheck(double, const std::vector<
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced service check for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Rescheduling next check for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Rescheduling next check for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -469,7 +479,8 @@ void ExternalCommandProcessor::EnableHostCheck(double, const std::vector<String>
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host checks for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Enabling active checks for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Enabling active checks for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -485,7 +496,8 @@ void ExternalCommandProcessor::DisableHostCheck(double, const std::vector<String
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host check non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Disabling active checks for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Disabling active checks for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -501,7 +513,8 @@ void ExternalCommandProcessor::EnableSvcCheck(double, const std::vector<String>&
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service check for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Enabling active checks for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Enabling active checks for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -517,7 +530,8 @@ void ExternalCommandProcessor::DisableSvcCheck(double, const std::vector<String>
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service check for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Disabling active checks for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Disabling active checks for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -548,7 +562,8 @@ void ExternalCommandProcessor::ScheduleForcedHostSvcChecks(double, const std::ve
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced host service checks for non-existent host '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Rescheduling next check for service '" + service->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Rescheduling next check for service '" << service->GetName() << "'";
 
                {
                        ObjectLock olock(service);
@@ -573,12 +588,14 @@ void ExternalCommandProcessor::ScheduleHostSvcChecks(double, const std::vector<S
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
                if (planned_check > service->GetNextCheck()) {
-                       Log(LogNotice, "ExternalCommandProcessor", "Ignoring reschedule request for service '" +
-                           service->GetName() + "' (next check is already sooner than requested check time)");
+                       Log(LogNotice, "ExternalCommandProcessor")
+                           << "Ignoring reschedule request for service '"
+                           << service->GetName() << "' (next check is already sooner than requested check time)";
                        continue;
                }
 
-               Log(LogNotice, "ExternalCommandProcessor", "Rescheduling next check for service '" + service->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Rescheduling next check for service '" << service->GetName() << "'";
 
                {
                        ObjectLock olock(service);
@@ -596,7 +613,8 @@ void ExternalCommandProcessor::EnableHostSvcChecks(double, const std::vector<Str
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host service checks for non-existent host '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Enabling active checks for service '" + service->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Enabling active checks for service '" << service->GetName() << "'";
                service->SetEnableActiveChecks(true);
        }
 }
@@ -609,7 +627,8 @@ void ExternalCommandProcessor::DisableHostSvcChecks(double, const std::vector<St
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host service checks for non-existent host '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Disabling active checks for service '" + service->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Disabling active checks for service '" << service->GetName() << "'";
 
                {
                        ObjectLock olock(service);
@@ -631,7 +650,8 @@ void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const std::vector<S
        if (service->GetState() == ServiceOK)
                BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is OK."));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Setting acknowledgement for service '" + service->GetName() + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Setting acknowledgement for service '" << service->GetName() << "'";
 
        service->AddComment(CommentAcknowledgement, arguments[5], arguments[6], 0);
        service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal);
@@ -650,7 +670,8 @@ void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::ve
        if (service->GetState() == ServiceOK)
                BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is OK."));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Setting timed acknowledgement for service '" + service->GetName() + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Setting timed acknowledgement for service '" << service->GetName() << "'";
 
        service->AddComment(CommentAcknowledgement, arguments[6], arguments[7], 0);
        service->AcknowledgeProblem(arguments[6], arguments[7], sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp);
@@ -663,7 +684,8 @@ void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const std::vecto
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot remove service acknowledgement for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Removing acknowledgement for service '" + service->GetName() + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Removing acknowledgement for service '" << service->GetName() << "'";
 
        {
                ObjectLock olock(service);
@@ -682,7 +704,8 @@ void ExternalCommandProcessor::AcknowledgeHostProblem(double, const std::vector<
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge host problem for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Setting acknowledgement for host '" + host->GetName() + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Setting acknowledgement for host '" << host->GetName() << "'";
 
        if (host->GetState() == HostUp)
                BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
@@ -701,7 +724,8 @@ void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const std::v
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge host problem with expire time for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Setting timed acknowledgement for host '" + host->GetName() + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Setting timed acknowledgement for host '" << host->GetName() << "'";
 
        if (host->GetState() == HostUp)
                BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
@@ -717,7 +741,8 @@ void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const std::vect
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot remove acknowledgement for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Removing acknowledgement for host '" + host->GetName() + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Removing acknowledgement for host '" << host->GetName() << "'";
 
        {
                ObjectLock olock(host);
@@ -735,7 +760,8 @@ void ExternalCommandProcessor::EnableHostgroupSvcChecks(double, const std::vecto
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
                BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
-                       Log(LogNotice, "ExternalCommandProcessor", "Enabling active checks for service '" + service->GetName() + "'");
+                       Log(LogNotice, "ExternalCommandProcessor")
+                           << "Enabling active checks for service '" << service->GetName() << "'";
 
                        {
                                ObjectLock olock(service);
@@ -755,7 +781,8 @@ void ExternalCommandProcessor::DisableHostgroupSvcChecks(double, const std::vect
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
                BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
-                       Log(LogNotice, "ExternalCommandProcessor", "Disabling active checks for service '" + service->GetName() + "'");
+                       Log(LogNotice, "ExternalCommandProcessor")
+                           << "Disabling active checks for service '" << service->GetName() << "'";
 
                        {
                                ObjectLock olock(service);
@@ -774,7 +801,8 @@ void ExternalCommandProcessor::EnableServicegroupSvcChecks(double, const std::ve
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup service checks for non-existent servicegroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Enabling active checks for service '" + service->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Enabling active checks for service '" << service->GetName() << "'";
 
                {
                        ObjectLock olock(service);
@@ -792,7 +820,8 @@ void ExternalCommandProcessor::DisableServicegroupSvcChecks(double, const std::v
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup service checks for non-existent servicegroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Disabling active checks for service '" + service->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Disabling active checks for service '" << service->GetName() << "'";
 
                {
                        ObjectLock olock(service);
@@ -809,7 +838,8 @@ void ExternalCommandProcessor::EnablePassiveHostChecks(double, const std::vector
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable passive host checks for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Enabling passive checks for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Enabling passive checks for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -825,7 +855,8 @@ void ExternalCommandProcessor::DisablePassiveHostChecks(double, const std::vecto
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable passive host checks for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Disabling passive checks for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Disabling passive checks for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -841,7 +872,8 @@ void ExternalCommandProcessor::EnablePassiveSvcChecks(double, const std::vector<
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service checks for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Enabling passive checks for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Enabling passive checks for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -857,7 +889,8 @@ void ExternalCommandProcessor::DisablePassiveSvcChecks(double, const std::vector
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service checks for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Disabling passive checks for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Disabling passive checks for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -874,7 +907,8 @@ void ExternalCommandProcessor::EnableServicegroupPassiveSvcChecks(double, const
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup passive service checks for non-existent servicegroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Enabling passive checks for service '" + service->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Enabling passive checks for service '" << service->GetName() << "'";
 
                {
                        ObjectLock olock(service);
@@ -892,7 +926,8 @@ void ExternalCommandProcessor::DisableServicegroupPassiveSvcChecks(double, const
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup passive service checks for non-existent servicegroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Disabling passive checks for service '" + service->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Disabling passive checks for service '" << service->GetName() << "'";
 
                {
                        ObjectLock olock(service);
@@ -911,7 +946,8 @@ void ExternalCommandProcessor::EnableHostgroupPassiveSvcChecks(double, const std
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
                BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
-                       Log(LogNotice, "ExternalCommandProcessor", "Enabling passive checks for service '" + service->GetName() + "'");
+                       Log(LogNotice, "ExternalCommandProcessor")
+                           << "Enabling passive checks for service '" << service->GetName() << "'";
 
                        {
                                ObjectLock olock(service);
@@ -931,7 +967,8 @@ void ExternalCommandProcessor::DisableHostgroupPassiveSvcChecks(double, const st
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
                BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
-                       Log(LogNotice, "ExternalCommandProcessor", "Disabling passive checks for service '" + service->GetName() + "'");
+                       Log(LogNotice, "ExternalCommandProcessor")
+                           << "Disabling passive checks for service '" << service->GetName() << "'";
 
                        {
                                ObjectLock olock(service);
@@ -957,13 +994,13 @@ void ExternalCommandProcessor::ProcessFile(double, const std::vector<String>& ar
                std::getline(ifp, line);
 
                try {
-                       Log(LogNotice, "compat", "Executing external command: " + line);
+                       Log(LogNotice, "compat")
+                           << "Executing external command: " << line;
 
                        Execute(line);
                } catch (const std::exception& ex) {
-                       std::ostringstream msgbuf;
-                       msgbuf << "External command failed: " << DiagnosticInformation(ex);
-                       Log(LogWarning, "ExternalCommandProcessor", msgbuf.str());
+                       Log(LogWarning, "ExternalCommandProcessor")
+                           << "External command failed: " << DiagnosticInformation(ex);
                }
        }
 
@@ -985,7 +1022,8 @@ void ExternalCommandProcessor::ScheduleSvcDowntime(double, const std::vector<Str
        if (triggeredByLegacy != 0)
                triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Creating downtime for service " + service->GetName());
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Creating downtime for service " << service->GetName();
        (void) service->AddDowntime(arguments[7], arguments[8],
            Convert::ToDouble(arguments[2]), Convert::ToDouble(arguments[3]),
            Convert::ToBool(arguments[4]), triggeredBy, Convert::ToDouble(arguments[6]));
@@ -994,7 +1032,8 @@ void ExternalCommandProcessor::ScheduleSvcDowntime(double, const std::vector<Str
 void ExternalCommandProcessor::DelSvcDowntime(double, const std::vector<String>& arguments)
 {
        int id = Convert::ToLong(arguments[0]);
-       Log(LogNotice, "ExternalCommandProcessor", "Removing downtime ID " + arguments[0]);
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Removing downtime ID " << arguments[0];
        String rid = Service::GetDowntimeIDFromLegacyID(id);
        Service::RemoveDowntime(rid, true);
 }
@@ -1011,7 +1050,8 @@ void ExternalCommandProcessor::ScheduleHostDowntime(double, const std::vector<St
        if (triggeredByLegacy != 0)
                triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Creating downtime for host " + host->GetName());
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Creating downtime for host " << host->GetName();
 
        (void) host->AddDowntime(arguments[6], arguments[7],
            Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
@@ -1021,7 +1061,8 @@ void ExternalCommandProcessor::ScheduleHostDowntime(double, const std::vector<St
 void ExternalCommandProcessor::DelHostDowntime(double, const std::vector<String>& arguments)
 {
        int id = Convert::ToLong(arguments[0]);
-       Log(LogNotice, "ExternalCommandProcessor", "Removing downtime ID " + arguments[0]);
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Removing downtime ID " << arguments[0];
        String rid = Service::GetDowntimeIDFromLegacyID(id);
        Service::RemoveDowntime(rid, true);
 }
@@ -1039,7 +1080,8 @@ void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const std::vector
                triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Creating downtime for service " + service->GetName());
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Creating downtime for service " << service->GetName();
                (void) service->AddDowntime(arguments[6], arguments[7],
                    Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
                    Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
@@ -1059,7 +1101,8 @@ void ExternalCommandProcessor::ScheduleHostgroupHostDowntime(double, const std::
                triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Creating downtime for host " + host->GetName());
+               Log(LogNotice, "ExternalCommandProcessor")
+                   <<  "Creating downtime for host " << host->GetName();
 
                (void) host->AddDowntime(arguments[6], arguments[7],
                    Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
@@ -1092,7 +1135,8 @@ void ExternalCommandProcessor::ScheduleHostgroupSvcDowntime(double, const std::v
        }
 
        BOOST_FOREACH(const Service::Ptr& service, services) {
-               Log(LogNotice, "ExternalCommandProcessor", "Creating downtime for service " + service->GetName());
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Creating downtime for service " << service->GetName();
                (void) service->AddDowntime(arguments[6], arguments[7],
                    Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
                    Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
@@ -1123,7 +1167,8 @@ void ExternalCommandProcessor::ScheduleServicegroupHostDowntime(double, const st
        }
 
        BOOST_FOREACH(const Host::Ptr& host, hosts) {
-               Log(LogNotice, "ExternalCommandProcessor", "Creating downtime for host " + host->GetName());
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Creating downtime for host " << host->GetName();
                (void) host->AddDowntime(arguments[6], arguments[7],
                    Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
                    Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
@@ -1143,7 +1188,8 @@ void ExternalCommandProcessor::ScheduleServicegroupSvcDowntime(double, const std
                triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
 
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Creating downtime for service " + service->GetName());
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Creating downtime for service " << service->GetName();
                (void) service->AddDowntime(arguments[6], arguments[7],
                    Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
                    Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
@@ -1157,14 +1203,16 @@ void ExternalCommandProcessor::AddHostComment(double, const std::vector<String>&
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot add host comment for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Creating comment for host " + host->GetName());
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Creating comment for host " << host->GetName();
        (void) host->AddComment(CommentUser, arguments[2], arguments[3], 0);
 }
 
 void ExternalCommandProcessor::DelHostComment(double, const std::vector<String>& arguments)
 {
        int id = Convert::ToLong(arguments[0]);
-       Log(LogNotice, "ExternalCommandProcessor", "Removing comment ID " + arguments[0]);
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Removing comment ID " << arguments[0];
        String rid = Service::GetCommentIDFromLegacyID(id);
        Service::RemoveComment(rid);
 }
@@ -1176,14 +1224,16 @@ void ExternalCommandProcessor::AddSvcComment(double, const std::vector<String>&
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot add service comment for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Creating comment for service " + service->GetName());
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Creating comment for service " << service->GetName();
        (void) service->AddComment(CommentUser, arguments[3], arguments[4], 0);
 }
 
 void ExternalCommandProcessor::DelSvcComment(double, const std::vector<String>& arguments)
 {
        int id = Convert::ToLong(arguments[0]);
-       Log(LogNotice, "ExternalCommandProcessor", "Removing comment ID " + arguments[0]);
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Removing comment ID " << arguments[0];
 
        String rid = Service::GetCommentIDFromLegacyID(id);
        Service::RemoveComment(rid);
@@ -1196,7 +1246,8 @@ void ExternalCommandProcessor::DelAllHostComments(double, const std::vector<Stri
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delete all host comments for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Removing all comments for host " + host->GetName());
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Removing all comments for host " << host->GetName();
        host->RemoveAllComments();
 }
 
@@ -1207,7 +1258,8 @@ void ExternalCommandProcessor::DelAllSvcComments(double, const std::vector<Strin
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delete all service comments for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Removing all comments for service " + service->GetName());
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Removing all comments for service " << service->GetName();
        service->RemoveAllComments();
 }
 
@@ -1220,7 +1272,8 @@ void ExternalCommandProcessor::SendCustomHostNotification(double, const std::vec
 
        int options = Convert::ToLong(arguments[1]);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Sending custom notification for host " + host->GetName());
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Sending custom notification for host " << host->GetName();
        if (options & 2) {
                ObjectLock olock(host);
                host->SetForceNextNotification(true);
@@ -1238,7 +1291,8 @@ void ExternalCommandProcessor::SendCustomSvcNotification(double, const std::vect
 
        int options = Convert::ToLong(arguments[2]);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Sending custom notification for service " + service->GetName());
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Sending custom notification for service " << service->GetName();
 
        if (options & 2) {
                ObjectLock olock(service);
@@ -1255,7 +1309,8 @@ void ExternalCommandProcessor::DelayHostNotification(double, const std::vector<S
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delay host notification for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Delaying notifications for host '" + host->GetName() + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Delaying notifications for host '" << host->GetName() << "'";
 
        BOOST_FOREACH(const Notification::Ptr& notification, host->GetNotifications()) {
                ObjectLock olock(notification);
@@ -1271,7 +1326,8 @@ void ExternalCommandProcessor::DelaySvcNotification(double, const std::vector<St
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delay service notification for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Delaying notifications for service " + service->GetName());
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Delaying notifications for service " << service->GetName();
 
        BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
                ObjectLock olock(notification);
@@ -1287,7 +1343,8 @@ void ExternalCommandProcessor::EnableHostNotifications(double, const std::vector
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host notifications for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Enabling notifications for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Enabling notifications for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -1303,7 +1360,8 @@ void ExternalCommandProcessor::DisableHostNotifications(double, const std::vecto
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host notifications for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Disabling notifications for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Disabling notifications for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -1319,7 +1377,8 @@ void ExternalCommandProcessor::EnableSvcNotifications(double, const std::vector<
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service notifications for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Enabling notifications for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Enabling notifications for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -1335,7 +1394,8 @@ void ExternalCommandProcessor::DisableSvcNotifications(double, const std::vector
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service notifications for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Disabling notifications for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Disabling notifications for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -1352,7 +1412,8 @@ void ExternalCommandProcessor::DisableHostgroupHostChecks(double, const std::vec
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup host checks for non-existent hostgroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Disabling active checks for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Disabling active checks for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -1370,7 +1431,8 @@ void ExternalCommandProcessor::DisableHostgroupPassiveHostChecks(double, const s
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup passive host checks for non-existent hostgroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Disabling passive checks for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Disabling passive checks for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -1390,7 +1452,8 @@ void ExternalCommandProcessor::DisableServicegroupHostChecks(double, const std::
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                Host::Ptr host = service->GetHost();
 
-               Log(LogNotice, "ExternalCommandProcessor", "Disabling active checks for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Disabling active checks for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -1410,7 +1473,8 @@ void ExternalCommandProcessor::DisableServicegroupPassiveHostChecks(double, cons
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                Host::Ptr host = service->GetHost();
 
-               Log(LogNotice, "ExternalCommandProcessor", "Disabling passive checks for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Disabling passive checks for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -1428,7 +1492,8 @@ void ExternalCommandProcessor::EnableHostgroupHostChecks(double, const std::vect
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup host checks for non-existent hostgroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Enabling active checks for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Enabling active checks for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -1446,7 +1511,8 @@ void ExternalCommandProcessor::EnableHostgroupPassiveHostChecks(double, const st
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup passive host checks for non-existent hostgroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Enabling passive checks for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Enabling passive checks for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -1466,7 +1532,8 @@ void ExternalCommandProcessor::EnableServicegroupHostChecks(double, const std::v
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                Host::Ptr host = service->GetHost();
 
-               Log(LogNotice, "ExternalCommandProcessor", "Enabling active checks for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Enabling active checks for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -1486,7 +1553,8 @@ void ExternalCommandProcessor::EnableServicegroupPassiveHostChecks(double, const
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                Host::Ptr host = service->GetHost();
 
-               Log(LogNotice, "ExternalCommandProcessor", "Enabling passive checks for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Enabling passive checks for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -1503,7 +1571,8 @@ void ExternalCommandProcessor::EnableHostFlapping(double, const std::vector<Stri
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host flapping for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Enabling flapping detection for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Enabling flapping detection for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -1519,7 +1588,8 @@ void ExternalCommandProcessor::DisableHostFlapping(double, const std::vector<Str
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host flapping for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Disabling flapping detection for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Disabling flapping detection for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -1535,7 +1605,8 @@ void ExternalCommandProcessor::EnableSvcFlapping(double, const std::vector<Strin
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service flapping for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Enabling flapping detection for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Enabling flapping detection for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -1551,7 +1622,8 @@ void ExternalCommandProcessor::DisableSvcFlapping(double, const std::vector<Stri
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service flapping for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Disabling flapping detection for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Disabling flapping detection for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -1653,7 +1725,8 @@ void ExternalCommandProcessor::ChangeSvcModattr(double, const std::vector<String
 
        int modifiedAttributes = Convert::ToLong(arguments[2]);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Updating modified attributes for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Updating modified attributes for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -1669,7 +1742,8 @@ void ExternalCommandProcessor::ChangeHostModattr(double, const std::vector<Strin
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update modified attributes for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Updating modified attributes for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Updating modified attributes for host '" << arguments[0] << "'";
 
        int modifiedAttributes = Convert::ToLong(arguments[1]);
 
@@ -1687,7 +1761,8 @@ void ExternalCommandProcessor::ChangeUserModattr(double, const std::vector<Strin
        if (!user)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update modified attributes for non-existent user '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Updating modified attributes for user '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Updating modified attributes for user '" << arguments[0] << "'";
 
        int modifiedAttributes = Convert::ToLong(arguments[1]);
 
@@ -1730,7 +1805,8 @@ void ExternalCommandProcessor::ChangeNotificationcommandModattr(double, const st
 
 void ExternalCommandProcessor::ChangeCommandModattrInternal(const Command::Ptr& command, int mod_attr)
 {
-       Log(LogNotice, "ExternalCommandProcessor", "Updating modified attributes for command '" + command->GetName() + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Updating modified attributes for command '" << command->GetName() << "'";
 
        {
                ObjectLock olock(command);
@@ -1748,7 +1824,8 @@ void ExternalCommandProcessor::ChangeNormalSvcCheckInterval(double, const std::v
 
        double interval = Convert::ToDouble(arguments[2]);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Updating check interval for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Updating check interval for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -1764,7 +1841,8 @@ void ExternalCommandProcessor::ChangeNormalHostCheckInterval(double, const std::
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update check interval for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Updating check interval for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Updating check interval for host '" << arguments[0] << "'";
 
        double interval = Convert::ToDouble(arguments[1]);
 
@@ -1784,7 +1862,8 @@ void ExternalCommandProcessor::ChangeRetrySvcCheckInterval(double, const std::ve
 
        double interval = Convert::ToDouble(arguments[2]);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Updating retry interval for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Updating retry interval for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -1800,7 +1879,8 @@ void ExternalCommandProcessor::ChangeRetryHostCheckInterval(double, const std::v
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update retry interval for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Updating retry interval for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Updating retry interval for host '" << arguments[0] << "'";
 
        double interval = Convert::ToDouble(arguments[1]);
 
@@ -1818,7 +1898,8 @@ void ExternalCommandProcessor::EnableHostEventHandler(double, const std::vector<
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable event handler for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Enabling event handler for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Enabling event handler for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -1834,7 +1915,8 @@ void ExternalCommandProcessor::DisableHostEventHandler(double, const std::vector
        if (!host)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable event handler for non-existent host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Disabling event handler for host '" + arguments[0] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Disabling event handler for host '" << arguments[0] << "'";
 
        {
                ObjectLock olock(host);
@@ -1850,7 +1932,8 @@ void ExternalCommandProcessor::EnableSvcEventHandler(double, const std::vector<S
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable event handler for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Enabling event handler for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Enabling event handler for service '" << arguments[1] << "'";
 
        {
                ObjectLock olock(service);
@@ -1866,7 +1949,8 @@ void ExternalCommandProcessor::DisableSvcEventHandler(double, const std::vector<
        if (!service)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable event handler for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Disabling event handler for service '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Disabling event handler for service '" << arguments[1] + "'";
 
        {
                ObjectLock olock(service);
@@ -1891,7 +1975,8 @@ void ExternalCommandProcessor::ChangeHostEventHandler(double, const std::vector<
                if (!command)
                        BOOST_THROW_EXCEPTION(std::invalid_argument("Event command '" + arguments[1] + "' does not exist."));
 
-               Log(LogNotice, "ExternalCommandProcessor", "Changing event handler for host '" + arguments[0] + "' to '" + arguments[1] + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Changing event handler for host '" << arguments[0] << "' to '" << arguments[1] << "'";
 
                {
                        ObjectLock olock(host);
@@ -1917,7 +2002,8 @@ void ExternalCommandProcessor::ChangeSvcEventHandler(double, const std::vector<S
                if (!command)
                        BOOST_THROW_EXCEPTION(std::invalid_argument("Event command '" + arguments[2] + "' does not exist."));
 
-               Log(LogNotice, "ExternalCommandProcessor", "Changing event handler for service '" + arguments[1] + "' to '" + arguments[2] + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Changing event handler for service '" << arguments[1] << "' to '" << arguments[2] << "'";
 
                {
                        ObjectLock olock(service);
@@ -1939,7 +2025,8 @@ void ExternalCommandProcessor::ChangeHostCheckCommand(double, const std::vector<
        if (!command)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Check command '" + arguments[1] + "' does not exist."));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Changing check command for host '" + arguments[0] + "' to '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Changing check command for host '" << arguments[0] << "' to '" << arguments[1] << "'";
 
        {
                ObjectLock olock(host);
@@ -1960,7 +2047,8 @@ void ExternalCommandProcessor::ChangeSvcCheckCommand(double, const std::vector<S
        if (!command)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Check command '" + arguments[2] + "' does not exist."));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Changing check command for service '" + arguments[1] + "' to '" + arguments[2] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Changing check command for service '" << arguments[1] << "' to '" << arguments[2] << "'";
 
        {
                ObjectLock olock(service);
@@ -1978,7 +2066,8 @@ void ExternalCommandProcessor::ChangeMaxHostCheckAttempts(double, const std::vec
 
        int attempts = Convert::ToLong(arguments[1]);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Changing max check attempts for host '" + arguments[0] + "' to '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Changing max check attempts for host '" << arguments[0] << "' to '" << arguments[1] << "'";
 
        {
                ObjectLock olock(host);
@@ -1996,7 +2085,8 @@ void ExternalCommandProcessor::ChangeMaxSvcCheckAttempts(double, const std::vect
 
        int attempts = Convert::ToLong(arguments[2]);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Changing max check attempts for service '" + arguments[1] + "' to '" + arguments[2] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Changing max check attempts for service '" << arguments[1] << "' to '" << arguments[2] << "'";
 
        {
                ObjectLock olock(service);
@@ -2017,7 +2107,8 @@ void ExternalCommandProcessor::ChangeHostCheckTimeperiod(double, const std::vect
        if (!tp)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Time period '" + arguments[1] + "' does not exist."));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Changing check period for host '" + arguments[0] + "' to '" + arguments[1] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Changing check period for host '" << arguments[0] << "' to '" << arguments[1] << "'";
 
        {
                ObjectLock olock(host);
@@ -2038,7 +2129,8 @@ void ExternalCommandProcessor::ChangeSvcCheckTimeperiod(double, const std::vecto
        if (!tp)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Time period '" + arguments[2] + "' does not exist."));
 
-       Log(LogNotice, "ExternalCommandProcessor", "Changing check period for service '" + arguments[1] + "' to '" + arguments[2] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Changing check period for service '" << arguments[1] << "' to '" << arguments[2] << "'";
 
        {
                ObjectLock olock(service);
@@ -2063,7 +2155,8 @@ void ExternalCommandProcessor::ChangeCustomHostVar(double, const std::vector<Str
 
        override_vars->Set(arguments[1], arguments[2]);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Changing custom var '" + arguments[1] + "' for host '" + arguments[0] + "' to value '" + arguments[2] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Changing custom var '" << arguments[1] << "' for host '" << arguments[0] << "' to value '" << arguments[2] << "'";
 
        {
                ObjectLock olock(host);
@@ -2089,8 +2182,9 @@ void ExternalCommandProcessor::ChangeCustomSvcVar(double, const std::vector<Stri
 
        override_vars->Set(arguments[2], arguments[3]);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Changing custom var '" + arguments[2] + "' for service '" + arguments[1] + "' on host '" +
-           arguments[0] + "' to value '" + arguments[3] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Changing custom var '" << arguments[2] << "' for service '" << arguments[1] << "' on host '"
+           << arguments[0] << "' to value '" << arguments[3] << "'";
 
        {
                ObjectLock olock(service);
@@ -2115,7 +2209,8 @@ void ExternalCommandProcessor::ChangeCustomUserVar(double, const std::vector<Str
 
        override_vars->Set(arguments[1], arguments[2]);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Changing custom var '" + arguments[1] + "' for user '" + arguments[0] + "' to value '" + arguments[2] + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Changing custom var '" << arguments[1] << "' for user '" << arguments[0] << "' to value '" << arguments[2] << "'";
 
        {
                ObjectLock olock(user);
@@ -2165,7 +2260,8 @@ void ExternalCommandProcessor::ChangeCustomCommandVarInternal(const Command::Ptr
 
        override_vars->Set(name, value);
 
-       Log(LogNotice, "ExternalCommandProcessor", "Changing custom var '" + name + "' for command '" + command->GetName() + "' to value '" + Convert::ToString(value) + "'");
+       Log(LogNotice, "ExternalCommandProcessor")
+           << "Changing custom var '" << name << "' for command '" << command->GetName() << "' to value '" << value << "'";
 
        {
                ObjectLock olock(command);
@@ -2182,7 +2278,8 @@ void ExternalCommandProcessor::EnableHostgroupHostNotifications(double, const st
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host notifications for non-existent hostgroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Enabling notifications for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Enabling notifications for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -2201,7 +2298,8 @@ void ExternalCommandProcessor::EnableHostgroupSvcNotifications(double, const std
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
                BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
-                       Log(LogNotice, "ExternalCommandProcessor", "Enabling notifications for service '" + service->GetName() + "'");
+                       Log(LogNotice, "ExternalCommandProcessor")
+                           << "Enabling notifications for service '" << service->GetName() << "'";
 
                        {
                                ObjectLock olock(service);
@@ -2220,7 +2318,8 @@ void ExternalCommandProcessor::DisableHostgroupHostNotifications(double, const s
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host notifications for non-existent hostgroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Disabling notifications for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Disabling notifications for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -2239,7 +2338,8 @@ void ExternalCommandProcessor::DisableHostgroupSvcNotifications(double, const st
 
        BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
                BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
-                       Log(LogNotice, "ExternalCommandProcessor", "Disabling notifications for service '" + service->GetName() + "'");
+                       Log(LogNotice, "ExternalCommandProcessor")
+                           << "Disabling notifications for service '" << service->GetName() << "'";
 
                        {
                                ObjectLock olock(service);
@@ -2260,7 +2360,8 @@ void ExternalCommandProcessor::EnableServicegroupHostNotifications(double, const
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                Host::Ptr host = service->GetHost();
 
-               Log(LogNotice, "ExternalCommandProcessor", "Enabling notifications for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Enabling notifications for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -2278,7 +2379,8 @@ void ExternalCommandProcessor::EnableServicegroupSvcNotifications(double, const
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service notifications for non-existent servicegroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Enabling notifications for service '" + service->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Enabling notifications for service '" << service->GetName() << "'";
 
                {
                        ObjectLock olock(service);
@@ -2298,7 +2400,8 @@ void ExternalCommandProcessor::DisableServicegroupHostNotifications(double, cons
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                Host::Ptr host = service->GetHost();
 
-               Log(LogNotice, "ExternalCommandProcessor", "Disabling notifications for host '" + host->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Disabling notifications for host '" << host->GetName() << "'";
 
                {
                        ObjectLock olock(host);
@@ -2316,7 +2419,8 @@ void ExternalCommandProcessor::DisableServicegroupSvcNotifications(double, const
                BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service notifications for non-existent servicegroup '" + arguments[0] + "'"));
 
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
-               Log(LogNotice, "ExternalCommandProcessor", "Disabling notifications for service '" + service->GetName() + "'");
+               Log(LogNotice, "ExternalCommandProcessor")
+                   << "Disabling notifications for service '" << service->GetName() << "'";
 
                {
                        ObjectLock olock(service);
index 2fa7c895d57666f25dba60c7cbb232d77ffd7e41..6ffcfeab180c0df51882107863d38ef988bb1bcf 100644 (file)
@@ -68,7 +68,8 @@ void LivestatusLogUtility::CreateLogIndexFileHandler(const String& path, std::ma
 
        stream.close();
 
-       Log(LogDebug, "LivestatusLogUtility", "Indexing log file: '" + path + "' with timestamp start: '" + Convert::ToString(ts_start) + "'.");
+       Log(LogDebug, "LivestatusLogUtility")
+           << "Indexing log file: '" << path << "' with timestamp start: '" << ts_start << "'.";
 
        index[ts_start] = path;
 }
@@ -104,7 +105,8 @@ void LivestatusLogUtility::CreateLogCache(std::map<time_t, String> index, Histor
 
                        /* no attributes available - invalid log line */
                        if (!log_entry_attrs) {
-                               Log(LogDebug, "LivestatusLogUtility", "Skipping invalid log line: '" + line + "'.");
+                               Log(LogDebug, "LivestatusLogUtility")
+                                   << "Skipping invalid log line: '" << line << "'.";
                                continue;
                        }
 
@@ -127,7 +129,8 @@ Dictionary::Ptr LivestatusLogUtility::GetAttributes(const String& text)
         */
        unsigned long time = atoi(text.SubStr(1, 11).CStr());
 
-       Log(LogDebug, "LivestatusLogUtility", "Processing log line: '" + text + "'.");
+       Log(LogDebug, "LivestatusLogUtility")
+           << "Processing log line: '" << text << "'.";
        bag->Set("time", time);
 
        size_t colon = text.FindFirstOf(':');
index 56733af20c4fbbdb59e1a8670501e9febcb47130..c73a8227ce827c1f41b0f0546d5afef1de7eadaf 100644 (file)
@@ -96,7 +96,8 @@ String LogTable::GetPrefix(void) const
 
 void LogTable::FetchRows(const AddRowFunction& addRowFn)
 {
-       Log(LogDebug, "LogTable", "Pre-selecting log file from " + Convert::ToString(m_TimeFrom) + " until " + Convert::ToString(m_TimeUntil));
+       Log(LogDebug, "LogTable")
+           << "Pre-selecting log file from " << m_TimeFrom << " until " << m_TimeUntil;
 
        /* create log file index */
        LivestatusLogUtility::CreateLogIndex(m_CompatLogPath, m_LogFileIndex);
index ac1ef37146deee58189e125d5f62d52033320f6a..defa0ae0e500e53382d617d4eebe6febbe09e3bb 100644 (file)
@@ -79,12 +79,14 @@ void GraphiteWriter::ReconnectTimerHandler(void)
 
        TcpSocket::Ptr socket = make_shared<TcpSocket>();
 
-       Log(LogNotice, "GraphiteWriter", "Reconnect to tcp socket on host '" + GetHost() + "' port '" + GetPort() + "'.");
+       Log(LogNotice, "GraphiteWriter")
+           << "Reconnecting to Graphite on host '" << GetHost() << "' port '" << GetPort() << "'.";
 
        try {
                socket->Connect(GetHost(), GetPort());
        } catch (std::exception&) {
-               Log(LogCritical, "GraphiteWriter", "Can't connect to tcp socket on host '" + GetHost() + "' port '" + GetPort() + "'.");
+               Log(LogCritical, "GraphiteWriter")
+                   << "Can't connect to Graphite on host '" << GetHost() << "' port '" << GetPort() << "'.";
                return;
        }
 
@@ -151,7 +153,8 @@ void GraphiteWriter::SendPerfdata(const String& prefix, const CheckResult::Ptr&
                        try {
                                pdv = PerfdataValue::Parse(val);
                        } catch (const std::exception&) {
-                               Log(LogWarning, "GraphiteWriter", "Ignoring invalid perfdata value: " + val);
+                               Log(LogWarning, "GraphiteWriter")
+                                   << "Ignoring invalid perfdata value: " << val;
                                continue;
                        }
                }
index 644bd115241211510ba8c0da5d1645f53ab9e881..13fe72efdb46a054d10cdebd61979bb772a8e893 100644 (file)
@@ -204,7 +204,8 @@ void ApiClient::MessageThreadProc(void)
                while (ProcessMessage())
                        ; /* empty loop body */
        } catch (const std::exception& ex) {
-               Log(LogWarning, "ApiClient", "Error while reading JSON-RPC message for identity '" + m_Identity + "': " + DiagnosticInformation(ex));
+               Log(LogWarning, "ApiClient")
+                   << "Error while reading JSON-RPC message for identity '" << m_Identity << "': " << DiagnosticInformation(ex);
        }
 
        Disconnect();
index 0a4170acd6d9de67c21e7dd440e50dbfb4b2fc59..d0a524247dab603b3d4106325903fedd14d1aada 100644 (file)
@@ -39,7 +39,8 @@ void ApiListener::ConfigGlobHandler(Dictionary::Ptr& config, const String& path,
 {
        CONTEXT("Creating config update for file '" + file + "'");
 
-       Log(LogNotice, "ApiListener", "Creating config update for file '" + file + "'");
+       Log(LogNotice, "ApiListener")
+           << "Creating config update for file '" << file << "'";
 
        std::ifstream fp(file.CStr());
        if (!fp)
@@ -74,7 +75,8 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio
                        configChange = true;
 
                        String path = configDir + "/" + kv.first;
-                       Log(LogInformation, "ApiListener", "Updating configuration file: " + path);
+                       Log(LogInformation, "ApiListener")
+                           << "Updating configuration file: " << path;
 
                        //pass the directory and generate a dir tree, if not existing already
                        Utility::MkDirP(Utility::DirName(path), 0755);
@@ -108,12 +110,12 @@ void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const
        String newDir = Application::GetZonesDir() + "/" + zone->GetName();
        String oldDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones/" + zone->GetName();
 
-       Log(LogInformation, "ApiListener", "Copying zone configuration files from '" + newDir + "' to  '" + oldDir + "'.");
+       Log(LogInformation, "ApiListener")
+           << "Copying zone configuration files from '" << newDir << "' to  '" << oldDir << "'.";
 
        if (!Utility::MkDir(oldDir, 0700)) {
-               std::ostringstream msgbuf;
-               msgbuf << "mkdir() for path '" << oldDir << "'failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
-               Log(LogCritical, "ApiListener",  msgbuf.str());
+               Log(LogCritical, "ApiListener")
+                   << "mkdir() for path '" << oldDir << "'failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
 
                BOOST_THROW_EXCEPTION(posix_error()
                        << boost::errinfo_api_function("mkdir")
@@ -161,16 +163,19 @@ void ApiListener::SendConfigUpdate(const ApiClient::Ptr& aclient)
                String zoneDir = zonesDir + "/" + zone->GetName();
 
                if (!zone->IsChildOf(azone) && !zone->IsGlobal()) {
-                       Log(LogNotice, "ApiListener", "Skipping sync for '" + zone->GetName() + "'. Not a child of zone '" + azone->GetName() + "'.");
+                       Log(LogNotice, "ApiListener")
+                           << "Skipping sync for '" << zone->GetName() << "'. Not a child of zone '" << azone->GetName() << "'.";
                        continue;
                }
                if (!Utility::PathExists(zoneDir)) {
-                       Log(LogNotice, "ApiListener", "Ignoring sync for '" + zone->GetName() + "'. Zone directory '" + zoneDir + "' does not exist.");
+                       Log(LogNotice, "ApiListener")
+                           << "Ignoring sync for '" << zone->GetName() << "'. Zone directory '" << zoneDir << "' does not exist.";
                        continue;
                }
 
                if (zone->IsGlobal())
-                       Log(LogInformation, "ApiListener", "Syncing global zone '" + zone->GetName() + "'.");
+                       Log(LogInformation, "ApiListener")
+                           << "Syncing global zone '" << zone->GetName() << "'.";
 
                configUpdate->Set(zone->GetName(), LoadConfigDir(zonesDir + "/" + zone->GetName()));
        }
@@ -199,7 +204,8 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin& origin, const Dictio
        }
 
        if (!listener->GetAcceptConfig()) {
-               Log(LogWarning, "ApiListener", "Ignoring config update. '" + listener->GetName() + "' does not accept config.");
+               Log(LogWarning, "ApiListener")
+                   << "Ignoring config update. '" << listener->GetName() << "' does not accept config.";
                return Empty;
        }
 
@@ -211,16 +217,16 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin& origin, const Dictio
                Zone::Ptr zone = Zone::GetByName(kv.first);
 
                if (!zone) {
-                       Log(LogWarning, "ApiListener", "Ignoring config update for unknown zone: " + kv.first);
+                       Log(LogWarning, "ApiListener")
+                           << "Ignoring config update for unknown zone: " << kv.first;
                        continue;
                }
 
                String oldDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones/" + zone->GetName();
 
                if (!Utility::MkDir(oldDir, 0700)) {
-                       std::ostringstream msgbuf;
-                       msgbuf << "mkdir() for path '" << oldDir << "'failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
-                       Log(LogCritical, "ApiListener",  msgbuf.str());
+                       Log(LogCritical, "ApiListener")
+                           << "mkdir() for path '" << oldDir << "'failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
 
                        BOOST_THROW_EXCEPTION(posix_error()
                                << boost::errinfo_api_function("mkdir")
index 9ec2f5e764a275dbfe0842f684efea39b44eb990..a17606517df3c417233626a9c6f398b3822c43a1 100644 (file)
@@ -46,23 +46,27 @@ void ApiListener::OnConfigLoaded(void)
        try {
                cert = GetX509Certificate(GetCertPath());
        } catch (const std::exception&) {
-               Log(LogCritical, "ApiListener", "Cannot get certificate from cert path: '" + GetCertPath() + "'.");
+               Log(LogCritical, "ApiListener")
+                   << "Cannot get certificate from cert path: '" << GetCertPath() << "'.";
                Application::Exit(EXIT_FAILURE);
        }
 
        try {
                SetIdentity(GetCertificateCN(cert));
        } catch (const std::exception&) {
-               Log(LogCritical, "ApiListener", "Cannot get certificate common name from cert path: '" + GetCertPath() + "'.");
+               Log(LogCritical, "ApiListener")
+                   << "Cannot get certificate common name from cert path: '" << GetCertPath() << "'.";
                Application::Exit(EXIT_FAILURE);
        }
 
-       Log(LogInformation, "ApiListener", "My API identity: " + GetIdentity());
+       Log(LogInformation, "ApiListener")
+           << "My API identity: " << GetIdentity();
 
        try {
                m_SSLContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath());
        } catch (const std::exception&) {
-               Log(LogCritical, "ApiListener", "Cannot make SSL context for cert path: '" + GetCertPath() + "' key path: '" + GetKeyPath() + "' ca path: '" + GetCaPath() + "'.");
+               Log(LogCritical, "ApiListener")
+                   << "Cannot make SSL context for cert path: '" << GetCertPath() << "' key path: '" << GetKeyPath() << "' ca path: '" << GetCaPath() << "'.";
                Application::Exit(EXIT_FAILURE);
        }
 
@@ -70,13 +74,15 @@ void ApiListener::OnConfigLoaded(void)
                try {
                        AddCRLToSSLContext(m_SSLContext, GetCrlPath());
                } catch (const std::exception&) {
-                       Log(LogCritical, "ApiListener", "Cannot add certificate revocation list to SSL context for crl path: '" + GetCrlPath() + "'.");
+                       Log(LogCritical, "ApiListener")
+                           << "Cannot add certificate revocation list to SSL context for crl path: '" << GetCrlPath() << "'.";
                        Application::Exit(EXIT_FAILURE);
                }
        }
 
        if (!Endpoint::GetByName(GetIdentity())) {
-               Log(LogCritical, "ApiListener", "Endpoint object for '" + GetIdentity() + "' is missing.");
+               Log(LogCritical, "ApiListener")
+                   << "Endpoint object for '" << GetIdentity() << "' is missing.";
                Application::Exit(EXIT_FAILURE);
        }
 
@@ -103,7 +109,8 @@ void ApiListener::Start(void)
 
        /* create the primary JSON-RPC listener */
        if (!AddListener(GetBindHost(), GetBindPort())) {
-               Log(LogCritical, "ApiListener", "Cannot add listener on host '" + GetBindHost() + "' for port '" + GetBindPort() + "'.");
+               Log(LogCritical, "ApiListener")
+                    << "Cannot add listener on host '" << GetBindHost() << "' for port '" << GetBindPort() << "'.";
                Application::Exit(EXIT_FAILURE);
        }
 
@@ -174,16 +181,16 @@ bool ApiListener::AddListener(const String& node, const String& service)
                return false;
        }
 
-       std::ostringstream s;
-       s << "Adding new listener: port " << service;
-       Log(LogInformation, "ApiListener", s.str());
+       Log(LogInformation, "ApiListener")
+           << "Adding new listener on port '" << service << "'";
 
        TcpSocket::Ptr server = make_shared<TcpSocket>();
 
        try {
                server->Bind(node, service, AF_UNSPEC);
        } catch (const std::exception&) {
-               Log(LogCritical, "ApiListener", "Cannot bind TCP socket for host '" + node + "' on port '" + service + "'.");
+               Log(LogCritical, "ApiListener")
+                   << "Cannot bind TCP socket for host '" << node << "' on port '" << service << "'.";
                return false;
        }
 
@@ -232,7 +239,8 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint)
        String host = endpoint->GetHost();
        String port = endpoint->GetPort();
 
-       Log(LogInformation, "ApiClient", "Reconnecting to API endpoint '" + endpoint->GetName() + "' via host '" + host + "' and port " + port);
+       Log(LogInformation, "ApiClient")
+           << "Reconnecting to API endpoint '" << endpoint->GetName() << "' via host '" << host << "' and port '" << port << "'";
 
        TcpSocket::Ptr client = make_shared<TcpSocket>();
 
@@ -245,11 +253,11 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint)
                endpoint->SetConnecting(false);
                client->Close();
 
-               std::ostringstream info, debug;
+               std::ostringstream info;
                info << "Cannot connect to host '" << host << "' on port '" << port << "'";
-               debug << info.str() << std::endl << DiagnosticInformation(ex);
                Log(LogCritical, "ApiListener", info.str());
-               Log(LogDebug, "ApiListener", debug.str());
+               Log(LogDebug, "ApiListener")
+                   << info.str() << "\n" << DiagnosticInformation(ex);
        }
 }
 
@@ -269,7 +277,7 @@ void ApiListener::NewClientHandler(const Socket::Ptr& client, ConnectionRole rol
                try {
                        tlsStream = make_shared<TlsStream>(client, role, m_SSLContext);
                } catch (const std::exception&) {
-                       Log(LogCritical, "ApiListener", "Cannot create tls stream from client connection.");
+                       Log(LogCritical, "ApiListener", "Cannot create TLS stream from client connection.");
                        return;
                }
        }
@@ -287,7 +295,8 @@ void ApiListener::NewClientHandler(const Socket::Ptr& client, ConnectionRole rol
        try {
                identity = GetCertificateCN(cert);
        } catch (const std::exception&) {
-               Log(LogCritical, "ApiListener", "Cannot get certificate common name from cert path: '" + GetCertPath() + "'.");
+               Log(LogCritical, "ApiListener")
+                   << "Cannot get certificate common name from cert path: '" << GetCertPath() << "'.";
                return;
        }
 
@@ -353,7 +362,8 @@ void ApiListener::ApiTimerHandler(void)
 
                if (!need) {
                        String path = GetApiDir() + "log/" + Convert::ToString(ts);
-                       Log(LogNotice, "ApiListener", "Removing old log file: " + path);
+                       Log(LogNotice, "ApiListener")
+                           << "Removing old log file: " << path;
                        (void)unlink(path.CStr());
                }
        }
@@ -417,21 +427,24 @@ void ApiListener::ApiTimerHandler(void)
                BOOST_FOREACH(const ApiClient::Ptr& client, endpoint->GetClients())
                        client->SendMessage(lmessage);
 
-               Log(LogNotice, "ApiListener", "Setting log position for identity '" + endpoint->GetName() + "': " +
-                       Utility::FormatDateTime("%Y/%m/%d %H:%M:%S", ts));
+               Log(LogNotice, "ApiListener")
+                   << "Setting log position for identity '" << endpoint->GetName() << "': "
+                   << Utility::FormatDateTime("%Y/%m/%d %H:%M:%S", ts);
        }
 
        Endpoint::Ptr master = GetMaster();
 
        if (master)
-               Log(LogNotice, "ApiListener", "Current zone master: " + master->GetName());
+               Log(LogNotice, "ApiListener")
+                   << "Current zone master: " << master->GetName();
 
        std::vector<String> names;
        BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjectsByType<Endpoint>())
                if (endpoint->IsConnected())
                        names.push_back(endpoint->GetName() + " (" + Convert::ToString(endpoint->GetClients().size()) + ")");
 
-       Log(LogNotice, "ApiListener", "Connected endpoints: " + Utility::NaturalJoin(names));
+       Log(LogNotice, "ApiListener")
+           << "Connected endpoints: " << Utility::NaturalJoin(names);
 }
 
 void ApiListener::RelayMessage(const MessageOrigin& origin, const DynamicObject::Ptr& secobj, const Dictionary::Ptr& message, bool log)
@@ -474,7 +487,8 @@ void ApiListener::SyncRelayMessage(const MessageOrigin& origin, const DynamicObj
        double ts = Utility::GetTime();
        message->Set("ts", ts);
 
-       Log(LogNotice, "ApiListener", "Relaying '" + message->Get("method") + "' message");
+       Log(LogNotice, "ApiListener")
+           << "Relaying '" << message->Get("method") << "' message";
 
        if (log)
                PersistMessage(message, secobj);
@@ -537,7 +551,8 @@ void ApiListener::SyncRelayMessage(const MessageOrigin& origin, const DynamicObj
                        ObjectLock olock(endpoint);
 
                        if (!endpoint->GetSyncing()) {
-                               Log(LogNotice, "ApiListener", "Sending message to '" + endpoint->GetName() + "'");
+                               Log(LogNotice, "ApiListener")
+                                   << "Sending message to '" << endpoint->GetName() << "'";
 
                                BOOST_FOREACH(const ApiClient::Ptr& client, endpoint->GetClients())
                                        client->SendMessage(message);
@@ -562,7 +577,8 @@ void ApiListener::OpenLogFile(void)
        std::fstream *fp = new std::fstream(path.CStr(), std::fstream::out | std::ofstream::app);
 
        if (!fp->good()) {
-               Log(LogWarning, "ApiListener", "Could not open spool file: " + path);
+               Log(LogWarning, "ApiListener")
+                   << "Could not open spool file: " << path;
                return;
        }
 
@@ -653,7 +669,8 @@ void ApiListener::ReplayLog(const ApiClient::Ptr& client)
                        if (ts < peer_ts)
                                continue;
 
-                       Log(LogNotice, "ApiListener", "Replaying log: " + path);
+                       Log(LogNotice, "ApiListener")
+                           << "Replaying log: " << path;
 
                        std::fstream *fp = new std::fstream(path.CStr(), std::fstream::in);
                        StdioStream::Ptr logStream = make_shared<StdioStream>(fp, true);
@@ -668,7 +685,8 @@ void ApiListener::ReplayLog(const ApiClient::Ptr& client)
 
                                        pmessage = JsonDeserialize(message);
                                } catch (const std::exception&) {
-                                       Log(LogWarning, "ApiListener", "Unexpected end-of-file for cluster log: " + path);
+                                       Log(LogWarning, "ApiListener")
+                                           << "Unexpected end-of-file for cluster log: " << path;
 
                                        /* Log files may be incomplete or corrupted. This is perfectly OK. */
                                        break;
@@ -703,7 +721,8 @@ void ApiListener::ReplayLog(const ApiClient::Ptr& client)
                        logStream->Close();
                }
 
-               Log(LogNotice, "ApiListener", "Replayed " + Convert::ToString(count) + " messages.");
+               Log(LogNotice, "ApiListener")
+                  << "Replayed " << count << " messages.";
 
                if (last_sync) {
                        {
index 59be361780c3de3fa14e904e6a1ad0641b22e324..4b66d839384790bf78736714bb979696928b67dc 100644 (file)
@@ -81,7 +81,8 @@ void Endpoint::RemoveClient(const ApiClient::Ptr& client)
                boost::mutex::scoped_lock lock(m_ClientsLock);
                m_Clients.erase(client);
 
-               Log(LogWarning, "ApiListener", "Removing API client for endpoint '" + GetName() + "'. " + Convert::ToString(m_Clients.size()) + " API clients left.");
+               Log(LogWarning, "ApiListener")
+                   << "Removing API client for endpoint '" << GetName() << "'. " << m_Clients.size() << " API clients left.";
        }
 
        bool is_master = ApiListener::GetInstance()->IsMaster();