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);
{
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);
{
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();
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);
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();
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);
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);
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);
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);
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);
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);
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);
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);
}
}
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);
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);
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);
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);
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."));
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."));
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
}
}
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]));
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);
}
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]),
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);
}
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]));
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]),
}
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]));
}
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]));
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]));
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);
}
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);
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();
}
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();
}
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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]);
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]);
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);
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);
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]);
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);
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]);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
}
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);
}
/* 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);
}
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;
}
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>();
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);
}
}
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;
}
}
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;
}
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());
}
}
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)
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);
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);
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;
}
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);
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;
logStream->Close();
}
- Log(LogNotice, "ApiListener", "Replayed " + Convert::ToString(count) + " messages.");
+ Log(LogNotice, "ApiListener")
+ << "Replayed " << count << " messages.";
if (last_sync) {
{