mirror of https://github.com/Icinga/icinga2.git
Made logging more modular.
This commit is contained in:
parent
b9fd84a87f
commit
7d859e2e18
|
@ -11,6 +11,8 @@ libbase_la_SOURCES = \
|
|||
component.h \
|
||||
configobject.cpp \
|
||||
configobject.h \
|
||||
consolelogger.cpp \
|
||||
consolelogger.h \
|
||||
dictionary.cpp \
|
||||
dictionary.h \
|
||||
event.cpp \
|
||||
|
@ -20,6 +22,8 @@ libbase_la_SOURCES = \
|
|||
fifo.cpp \
|
||||
fifo.h \
|
||||
i2-base.h \
|
||||
logger.cpp \
|
||||
logger.h \
|
||||
object.cpp \
|
||||
object.h \
|
||||
objectset.cpp \
|
||||
|
|
|
@ -23,14 +23,12 @@
|
|||
# include <ltdl.h>
|
||||
#endif
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
Application::Ptr I2_EXPORT Application::m_Instance;
|
||||
bool I2_EXPORT Application::m_ShuttingDown = false;
|
||||
bool I2_EXPORT Application::m_Debugging = false;
|
||||
Application::Ptr Application::m_Instance;
|
||||
bool Application::m_ShuttingDown = false;
|
||||
bool Application::m_Debugging = false;
|
||||
boost::thread::id Application::m_MainThreadID;
|
||||
|
||||
/**
|
||||
* Constructor for the Application class.
|
||||
|
@ -136,7 +134,7 @@ Component::Ptr Application::LoadComponent(const string& path,
|
|||
Component::Ptr component;
|
||||
Component *(*pCreateComponent)();
|
||||
|
||||
Log(LogInformation, "base", "Loading component '" + path + "'");
|
||||
Logger::Write(LogInformation, "base", "Loading component '" + path + "'");
|
||||
|
||||
#ifdef _WIN32
|
||||
HMODULE hModule = LoadLibrary(path.c_str());
|
||||
|
@ -190,7 +188,7 @@ void Application::UnregisterComponent(const Component::Ptr& component)
|
|||
{
|
||||
string name = component->GetName();
|
||||
|
||||
Log(LogInformation, "base", "Unloading component '" + name + "'");
|
||||
Logger::Write(LogInformation, "base", "Unloading component '" + name + "'");
|
||||
map<string, Component::Ptr>::iterator i = m_Components.find(name);
|
||||
if (i != m_Components.end())
|
||||
m_Components.erase(i);
|
||||
|
@ -214,50 +212,6 @@ Component::Ptr Application::GetComponent(const string& name) const
|
|||
return i->second;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a message to the application's log.
|
||||
*
|
||||
* @param severity The message severity.
|
||||
* @param facility The log facility.
|
||||
* @param message The message.
|
||||
*/
|
||||
void Application::Log(LogSeverity severity, const string& facility, const string& message)
|
||||
{
|
||||
char timestamp[100];
|
||||
|
||||
// TODO: make this configurable
|
||||
if (/*!IsDebugging() && */severity < LogInformation)
|
||||
return;
|
||||
|
||||
string severityStr;
|
||||
switch (severity) {
|
||||
case LogDebug:
|
||||
severityStr = "debug";
|
||||
break;
|
||||
case LogInformation:
|
||||
severityStr = "info";
|
||||
break;
|
||||
case LogWarning:
|
||||
severityStr = "warning";
|
||||
break;
|
||||
case LogCritical:
|
||||
severityStr = "critical";
|
||||
break;
|
||||
default:
|
||||
assert(!"Invalid severity specified.");
|
||||
}
|
||||
|
||||
time_t now;
|
||||
time(&now);
|
||||
tm tmnow = *localtime(&now);
|
||||
|
||||
strftime(timestamp, sizeof(timestamp), "%Y/%m/%d %H:%M:%S", &tmnow);
|
||||
|
||||
cout << "[" << timestamp << "] "
|
||||
<< severityStr << "/" << facility << ": "
|
||||
<< message << endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the directory the application's binary is contained in.
|
||||
*
|
||||
|
@ -351,6 +305,11 @@ bool Application::IsDebugging(void)
|
|||
return m_Debugging;
|
||||
}
|
||||
|
||||
bool Application::IsMainThread(void)
|
||||
{
|
||||
return (boost::this_thread::get_id() == m_MainThreadID);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/**
|
||||
* Signal handler for SIGINT. Prepares the application for cleanly
|
||||
|
@ -405,6 +364,9 @@ int Application::Run(int argc, char **argv)
|
|||
int result;
|
||||
|
||||
assert(!Application::m_Instance);
|
||||
|
||||
m_MainThreadID = boost::this_thread::get_id();
|
||||
|
||||
Application::m_Instance = GetSelf();
|
||||
|
||||
#ifndef _WIN32
|
||||
|
@ -433,9 +395,9 @@ int Application::Run(int argc, char **argv)
|
|||
} catch (const std::exception& ex) {
|
||||
Application::m_Instance.reset();
|
||||
|
||||
Application::Log(LogCritical, "base", "---");
|
||||
Application::Log(LogCritical, "base", "Exception: " + Utility::GetTypeName(ex));
|
||||
Application::Log(LogCritical, "base", "Message: " + string(ex.what()));
|
||||
Logger::Write(LogCritical, "base", "---");
|
||||
Logger::Write(LogCritical, "base", "Exception: " + Utility::GetTypeName(ex));
|
||||
Logger::Write(LogCritical, "base", "Message: " + string(ex.what()));
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -22,19 +22,6 @@
|
|||
|
||||
namespace icinga {
|
||||
|
||||
/**
|
||||
* Log severity.
|
||||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
enum LogSeverity
|
||||
{
|
||||
LogDebug,
|
||||
LogInformation,
|
||||
LogWarning,
|
||||
LogCritical
|
||||
};
|
||||
|
||||
class Component;
|
||||
|
||||
/**
|
||||
|
@ -58,8 +45,6 @@ public:
|
|||
|
||||
static void Shutdown(void);
|
||||
|
||||
static void Log(LogSeverity severity, const string& facility, const string& message);
|
||||
|
||||
shared_ptr<Component> LoadComponent(const string& path,
|
||||
const ConfigObject::Ptr& componentConfig);
|
||||
void RegisterComponent(const shared_ptr<Component>& component);
|
||||
|
@ -69,6 +54,8 @@ public:
|
|||
|
||||
static bool IsDebugging(void);
|
||||
|
||||
static bool IsMainThread(void);
|
||||
|
||||
protected:
|
||||
void RunEventLoop(void);
|
||||
string GetExeDirectory(void) const;
|
||||
|
@ -82,6 +69,7 @@ private:
|
|||
were loaded by the application. */
|
||||
vector<string> m_Arguments; /**< Command-line arguments */
|
||||
static bool m_Debugging; /**< Whether debugging is enabled. */
|
||||
static boost::thread::id m_MainThreadID; /**< ID of the main thread. */
|
||||
|
||||
#ifndef _WIN32
|
||||
static void SigIntHandler(int signum);
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#include "i2-base.h"
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
ConsoleLogger::ConsoleLogger(LogSeverity minSeverity)
|
||||
: Logger(minSeverity)
|
||||
{ }
|
||||
|
||||
void ConsoleLogger::ProcessLogEntry(const LogEntry& entry)
|
||||
{
|
||||
char timestamp[100];
|
||||
|
||||
string severityStr;
|
||||
switch (entry.Severity) {
|
||||
case LogDebug:
|
||||
severityStr = "debug";
|
||||
break;
|
||||
case LogInformation:
|
||||
severityStr = "info";
|
||||
break;
|
||||
case LogWarning:
|
||||
severityStr = "warning";
|
||||
break;
|
||||
case LogCritical:
|
||||
severityStr = "critical";
|
||||
break;
|
||||
default:
|
||||
assert(!"Invalid severity specified.");
|
||||
}
|
||||
|
||||
tm tmnow = *localtime(&entry.Timestamp);
|
||||
|
||||
strftime(timestamp, sizeof(timestamp), "%Y/%m/%d %H:%M:%S", &tmnow);
|
||||
|
||||
std::cout << "[" << timestamp << "] "
|
||||
<< severityStr << "/" << entry.Facility << ": "
|
||||
<< entry.Message << std::endl;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef CONSOLELOGGER_H
|
||||
#define CONSOLELOGGER_H
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class ConsoleLogger : public Logger
|
||||
{
|
||||
public:
|
||||
ConsoleLogger(LogSeverity minSeverity);
|
||||
|
||||
protected:
|
||||
virtual void ProcessLogEntry(const LogEntry& entry);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* CONSOLELOGGER_H */
|
|
@ -43,7 +43,14 @@ bool Event::Wait(vector<Event::Ptr> *events, const system_time& wait_until)
|
|||
|
||||
void Event::Post(const Event::Ptr& ev)
|
||||
{
|
||||
mutex::scoped_lock lock(m_Mutex);
|
||||
m_Events.push_back(ev);
|
||||
m_EventAvailable.notify_all();
|
||||
if (Application::IsMainThread()) {
|
||||
ev->OnEventDelivered();
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
mutex::scoped_lock lock(m_Mutex);
|
||||
m_Events.push_back(ev);
|
||||
m_EventAvailable.notify_all();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,5 +168,7 @@ using boost::system_time;
|
|||
#include "application.h"
|
||||
#include "component.h"
|
||||
#include "threadpool.h"
|
||||
#include "logger.h"
|
||||
#include "consolelogger.h"
|
||||
|
||||
#endif /* I2BASE_H */
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "i2-base.h"
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
vector<Logger::Ptr> Logger::m_Loggers;
|
||||
|
||||
Logger::Logger(LogSeverity minSeverity)
|
||||
: m_MinSeverity(minSeverity)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Writes a message to the application's log.
|
||||
*
|
||||
* @param severity The message severity.
|
||||
* @param facility The log facility.
|
||||
* @param message The message.
|
||||
*/
|
||||
void Logger::Write(LogSeverity severity, const string& facility,
|
||||
const string& message)
|
||||
{
|
||||
LogEntry entry;
|
||||
time(&entry.Timestamp);
|
||||
entry.Severity = severity;
|
||||
entry.Facility = facility;
|
||||
entry.Message = message;
|
||||
|
||||
Event::Ptr ev = boost::make_shared<Event>();
|
||||
ev->OnEventDelivered.connect(boost::bind(&Logger::ForwardLogEntry, entry));
|
||||
Event::Post(ev);
|
||||
}
|
||||
|
||||
void Logger::RegisterLogger(const Logger::Ptr& logger)
|
||||
{
|
||||
m_Loggers.push_back(logger);
|
||||
}
|
||||
|
||||
LogSeverity Logger::GetMinSeverity(void) const
|
||||
{
|
||||
return m_MinSeverity;
|
||||
}
|
||||
|
||||
void Logger::ForwardLogEntry(const LogEntry& entry)
|
||||
{
|
||||
vector<Logger::Ptr>::iterator it;
|
||||
for (it = m_Loggers.begin(); it != m_Loggers.end(); it++) {
|
||||
Logger::Ptr logger = *it;
|
||||
|
||||
if (entry.Severity >= logger->GetMinSeverity())
|
||||
logger->ProcessLogEntry(entry);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
/**
|
||||
* Log severity.
|
||||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
enum LogSeverity
|
||||
{
|
||||
LogDebug,
|
||||
LogInformation,
|
||||
LogWarning,
|
||||
LogCritical
|
||||
};
|
||||
|
||||
struct LogEntry {
|
||||
time_t Timestamp;
|
||||
LogSeverity Severity;
|
||||
string Facility;
|
||||
string Message;
|
||||
};
|
||||
|
||||
class I2_BASE_API Logger : public Object
|
||||
{
|
||||
public:
|
||||
typedef shared_ptr<Logger> Ptr;
|
||||
typedef weak_ptr<Logger> WeakPtr;
|
||||
|
||||
Logger(LogSeverity minSeverity = LogDebug);
|
||||
|
||||
static void Write(LogSeverity severity, const string& facility,
|
||||
const string& message);
|
||||
|
||||
static void RegisterLogger(const Logger::Ptr& logger);
|
||||
|
||||
protected:
|
||||
virtual void ProcessLogEntry(const LogEntry& entry) = 0;
|
||||
|
||||
LogSeverity GetMinSeverity(void) const;
|
||||
|
||||
private:
|
||||
LogSeverity m_MinSeverity;
|
||||
|
||||
static vector<Logger::Ptr> m_Loggers;
|
||||
|
||||
static void ForwardLogEntry(const LogEntry& entry);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* LOGGER_H */
|
|
@ -81,7 +81,7 @@ long Timer::ProcessTimers(void)
|
|||
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Timers took " << et - st << " seconds";
|
||||
Application::Log(LogDebug, "base", msgbuf.str());
|
||||
Logger::Write(LogDebug, "base", msgbuf.str());
|
||||
|
||||
return wakeup;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ void Timer::Call(void)
|
|||
if (et - st > 3) {
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Timer call took " << et - st << " seconds.";
|
||||
Application::Log(LogWarning, "base", msgbuf.str());
|
||||
Logger::Write(LogWarning, "base", msgbuf.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ void CheckerComponent::CheckTimerHandler(void)
|
|||
time_t now;
|
||||
time(&now);
|
||||
|
||||
Application::Log(LogDebug, "checker", "CheckTimerHandler entered.");
|
||||
Logger::Write(LogDebug, "checker", "CheckTimerHandler entered.");
|
||||
|
||||
long tasks = 0;
|
||||
|
||||
|
@ -74,7 +74,7 @@ void CheckerComponent::CheckTimerHandler(void)
|
|||
|
||||
m_Services.pop();
|
||||
|
||||
Application::Log(LogDebug, "checker", "Executing service check for '" + service.GetName() + "'");
|
||||
Logger::Write(LogDebug, "checker", "Executing service check for '" + service.GetName() + "'");
|
||||
|
||||
m_PendingServices.insert(service.GetConfigObject());
|
||||
|
||||
|
@ -84,18 +84,18 @@ void CheckerComponent::CheckTimerHandler(void)
|
|||
tasks++;
|
||||
}
|
||||
|
||||
Application::Log(LogDebug, "checker", "CheckTimerHandler: past loop.");
|
||||
Logger::Write(LogDebug, "checker", "CheckTimerHandler: past loop.");
|
||||
|
||||
CheckTask::FlushQueue();
|
||||
|
||||
stringstream msgbuf;
|
||||
msgbuf << "CheckTimerHandler: created " << tasks << " tasks";
|
||||
Application::Log(LogInformation, "checker", msgbuf.str());
|
||||
Logger::Write(LogInformation, "checker", msgbuf.str());
|
||||
}
|
||||
|
||||
void CheckerComponent::ResultTimerHandler(void)
|
||||
{
|
||||
Application::Log(LogDebug, "checker", "ResultTimerHandler entered.");
|
||||
Logger::Write(LogDebug, "checker", "ResultTimerHandler entered.");
|
||||
|
||||
time_t now;
|
||||
time(&now);
|
||||
|
@ -115,7 +115,7 @@ void CheckerComponent::ResultTimerHandler(void)
|
|||
continue;
|
||||
|
||||
CheckResult result = task->GetResult();
|
||||
Application::Log(LogDebug, "checker", "Got result for service '" + service.GetName() + "'");
|
||||
Logger::Write(LogDebug, "checker", "Got result for service '" + service.GetName() + "'");
|
||||
|
||||
long execution_time = result.GetExecutionEnd() - result.GetExecutionStart();
|
||||
long latency = (result.GetScheduleEnd() - result.GetScheduleStart()) - execution_time;
|
||||
|
@ -161,19 +161,19 @@ void CheckerComponent::ResultTimerHandler(void)
|
|||
if (min_latency > 5) {
|
||||
stringstream latwarn;
|
||||
latwarn << "We can't keep up with the checks: minimum latency is " << min_latency << " seconds";
|
||||
Application::Log(LogWarning, "checker", latwarn.str());
|
||||
Logger::Write(LogWarning, "checker", latwarn.str());
|
||||
}
|
||||
|
||||
{
|
||||
stringstream msgbuf;
|
||||
msgbuf << "ResultTimerHandler: " << results << " results (" << failed << " failed); latency: avg=" << avg_latency / (results ? results : 1) << ", min=" << min_latency << ", max: " << max_latency;
|
||||
Application::Log(LogInformation, "checker", msgbuf.str());
|
||||
Logger::Write(LogInformation, "checker", msgbuf.str());
|
||||
}
|
||||
|
||||
{
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Pending services: " << m_PendingServices.size() << "; Idle services: " << m_Services.size();
|
||||
Application::Log(LogInformation, "checker", msgbuf.str());
|
||||
Logger::Write(LogInformation, "checker", msgbuf.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ void CheckerComponent::AssignServiceRequestHandler(const Endpoint::Ptr& sender,
|
|||
Service service(object);
|
||||
m_Services.push(service);
|
||||
|
||||
Application::Log(LogDebug, "checker", "Accepted delegation for service '" + service.GetName() + "'");
|
||||
Logger::Write(LogDebug, "checker", "Accepted delegation for service '" + service.GetName() + "'");
|
||||
|
||||
string id;
|
||||
if (request.GetID(&id)) {
|
||||
|
@ -206,7 +206,7 @@ void CheckerComponent::AssignServiceRequestHandler(const Endpoint::Ptr& sender,
|
|||
|
||||
void CheckerComponent::ClearServicesRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
|
||||
{
|
||||
Application::Log(LogInformation, "checker", "Clearing service delegations.");
|
||||
Logger::Write(LogInformation, "checker", "Clearing service delegations.");
|
||||
|
||||
/* clear the services lists */
|
||||
m_Services = ServiceQueue();
|
||||
|
|
|
@ -39,7 +39,7 @@ void ConfigFileComponent::Start(void)
|
|||
|
||||
vector<ConfigItem::Ptr> configItems = ConfigCompiler::CompileFile(filename);
|
||||
|
||||
Application::Log(LogInformation, "configfile", "Executing config items...");
|
||||
Logger::Write(LogInformation, "configfile", "Executing config items...");
|
||||
|
||||
vector<ConfigItem::Ptr>::iterator it;
|
||||
for (it = configItems.begin(); it != configItems.end(); it++) {
|
||||
|
|
|
@ -99,7 +99,7 @@ void DelegationComponent::AssignService(const Endpoint::Ptr& checker, const Serv
|
|||
params.Set("service", service.GetConfigObject()->GetProperties());
|
||||
request.SetParams(params);
|
||||
|
||||
Application::Log(LogDebug, "delegation", "Trying to delegate service '" + service.GetName() + "'");
|
||||
Logger::Write(LogDebug, "delegation", "Trying to delegate service '" + service.GetName() + "'");
|
||||
|
||||
EndpointManager::GetInstance()->SendUnicastMessage(m_Endpoint, checker, request);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ void DelegationComponent::ClearServices(const Endpoint::Ptr& checker)
|
|||
{
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Clearing assigned services for endpoint '" << checker->GetIdentity() << "'";
|
||||
Application::Log(LogInformation, "delegation", msgbuf.str());
|
||||
Logger::Write(LogInformation, "delegation", msgbuf.str());
|
||||
|
||||
RequestMessage request;
|
||||
request.SetMethod("checker::ClearServices");
|
||||
|
@ -227,7 +227,7 @@ void DelegationComponent::DelegationTimerHandler(void)
|
|||
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Service: " << service.GetName() << ", candidates: " << candidates.size();
|
||||
Application::Log(LogDebug, "delegation", msgbuf.str());
|
||||
Logger::Write(LogDebug, "delegation", msgbuf.str());
|
||||
|
||||
for (cit = candidates.begin(); cit != candidates.end(); cit++)
|
||||
avg_services += histogram[*cit];
|
||||
|
@ -275,7 +275,7 @@ void DelegationComponent::DelegationTimerHandler(void)
|
|||
for (hit = histogram.begin(); hit != histogram.end(); hit++) {
|
||||
stringstream msgbuf;
|
||||
msgbuf << "histogram: " << hit->first->GetIdentity() << " - " << hit->second;
|
||||
Application::Log(LogInformation, "delegation", msgbuf.str());
|
||||
Logger::Write(LogInformation, "delegation", msgbuf.str());
|
||||
}
|
||||
|
||||
if (delegated > 0) {
|
||||
|
@ -299,7 +299,7 @@ void DelegationComponent::DelegationTimerHandler(void)
|
|||
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Updated delegations for " << delegated << " services";
|
||||
Application::Log(LogInformation, "delegation", msgbuf.str());
|
||||
Logger::Write(LogInformation, "delegation", msgbuf.str());
|
||||
}
|
||||
|
||||
void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
|
||||
|
|
|
@ -66,7 +66,7 @@ void DemoComponent::Stop(void)
|
|||
*/
|
||||
void DemoComponent::DemoTimerHandler(void)
|
||||
{
|
||||
Application::Log(LogInformation, "demo", "Sending multicast 'hello world' message.");
|
||||
Logger::Write(LogInformation, "demo", "Sending multicast 'hello world' message.");
|
||||
|
||||
RequestMessage request;
|
||||
request.SetMethod("demo::HelloWorld");
|
||||
|
@ -79,7 +79,7 @@ void DemoComponent::DemoTimerHandler(void)
|
|||
*/
|
||||
void DemoComponent::HelloWorldRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
|
||||
{
|
||||
Application::Log(LogInformation, "demo", "Got 'hello world' from address=" + sender->GetAddress() + ", identity=" + sender->GetIdentity());
|
||||
Logger::Write(LogInformation, "demo", "Got 'hello world' from address=" + sender->GetAddress() + ", identity=" + sender->GetIdentity());
|
||||
}
|
||||
|
||||
EXPORT_COMPONENT(demo, DemoComponent);
|
||||
|
|
|
@ -93,7 +93,7 @@ void DiscoveryComponent::CheckExistingEndpoint(const Endpoint::Ptr& self, const
|
|||
return;
|
||||
|
||||
if (self->GetIdentity() == other->GetIdentity()) {
|
||||
Application::Log(LogWarning, "discovery", "Detected duplicate identity:" + other->GetIdentity() + " - Disconnecting old endpoint.");
|
||||
Logger::Write(LogWarning, "discovery", "Detected duplicate identity:" + other->GetIdentity() + " - Disconnecting old endpoint.");
|
||||
|
||||
other->Stop();
|
||||
EndpointManager::GetInstance()->UnregisterEndpoint(other);
|
||||
|
@ -122,7 +122,7 @@ void DiscoveryComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
|
|||
string identity = endpoint->GetIdentity();
|
||||
|
||||
if (identity == EndpointManager::GetInstance()->GetIdentity()) {
|
||||
Application::Log(LogWarning, "discovery", "Detected loop-back connection - Disconnecting endpoint.");
|
||||
Logger::Write(LogWarning, "discovery", "Detected loop-back connection - Disconnecting endpoint.");
|
||||
|
||||
endpoint->Stop();
|
||||
EndpointManager::GetInstance()->UnregisterEndpoint(endpoint);
|
||||
|
@ -521,7 +521,7 @@ void DiscoveryComponent::DiscoveryTimerHandler(void)
|
|||
} catch (const std::exception& ex) {
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Exception while trying to reconnect to endpoint '" << endpoint->GetIdentity() << "': " << ex.what();;
|
||||
Application::Log(LogInformation, "discovery", msgbuf.str());
|
||||
Logger::Write(LogInformation, "discovery", msgbuf.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,8 +370,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
|
|||
*yy_cp = '\0'; \
|
||||
yyg->yy_c_buf_p = yy_cp;
|
||||
|
||||
#define YY_NUM_RULES 23
|
||||
#define YY_END_OF_BUFFER 24
|
||||
#define YY_NUM_RULES 22
|
||||
#define YY_END_OF_BUFFER 23
|
||||
/* This struct is not used in this scanner,
|
||||
but its presence is necessary. */
|
||||
struct yy_trans_info
|
||||
|
@ -379,16 +379,15 @@ struct yy_trans_info
|
|||
flex_int32_t yy_verify;
|
||||
flex_int32_t yy_nxt;
|
||||
};
|
||||
static yyconst flex_int16_t yy_accept[72] =
|
||||
static yyconst flex_int16_t yy_accept[70] =
|
||||
{ 0,
|
||||
0, 0, 0, 0, 24, 22, 21, 21, 22, 22,
|
||||
22, 22, 22, 22, 9, 10, 7, 7, 7, 7,
|
||||
7, 7, 17, 18, 21, 0, 8, 20, 13, 11,
|
||||
12, 15, 0, 14, 9, 7, 7, 7, 7, 7,
|
||||
7, 17, 16, 19, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 6, 7, 7, 7, 7, 2,
|
||||
7, 7, 7, 7, 3, 7, 4, 7, 1, 5,
|
||||
0
|
||||
0, 0, 0, 0, 23, 21, 20, 20, 21, 21,
|
||||
21, 21, 21, 9, 10, 7, 7, 7, 7, 7,
|
||||
7, 17, 18, 20, 0, 8, 13, 11, 12, 15,
|
||||
0, 14, 9, 7, 7, 7, 7, 7, 7, 17,
|
||||
16, 19, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 6, 7, 7, 7, 7, 2, 7, 7,
|
||||
7, 7, 3, 7, 4, 7, 1, 5, 0
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_ec[256] =
|
||||
|
@ -396,17 +395,17 @@ static yyconst flex_int32_t yy_ec[256] =
|
|||
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 1, 4, 5, 1, 1, 1, 1, 1,
|
||||
1, 6, 7, 1, 8, 1, 9, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 1, 1, 1,
|
||||
11, 1, 1, 1, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||
1, 1, 1, 1, 12, 1, 13, 14, 15, 16,
|
||||
1, 2, 1, 4, 1, 1, 1, 1, 1, 1,
|
||||
1, 5, 6, 1, 7, 1, 8, 9, 9, 9,
|
||||
9, 9, 9, 9, 9, 9, 9, 1, 1, 1,
|
||||
10, 1, 1, 1, 11, 11, 11, 11, 11, 11,
|
||||
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||
1, 1, 1, 1, 11, 1, 12, 13, 14, 15,
|
||||
|
||||
17, 12, 12, 18, 19, 20, 12, 21, 12, 22,
|
||||
23, 12, 12, 24, 25, 26, 27, 12, 12, 12,
|
||||
12, 12, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
16, 11, 11, 17, 18, 19, 11, 20, 11, 21,
|
||||
22, 11, 11, 23, 24, 25, 26, 11, 11, 11,
|
||||
11, 11, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
|
@ -423,78 +422,76 @@ static yyconst flex_int32_t yy_ec[256] =
|
|||
1, 1, 1, 1, 1
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_meta[28] =
|
||||
static yyconst flex_int32_t yy_meta[27] =
|
||||
{ 0,
|
||||
1, 1, 2, 1, 1, 3, 1, 4, 1, 4,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4
|
||||
1, 1, 2, 1, 3, 1, 4, 1, 4, 1,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_base[78] =
|
||||
static yyconst flex_int16_t yy_base[75] =
|
||||
{ 0,
|
||||
0, 0, 90, 89, 94, 97, 26, 28, 89, 0,
|
||||
81, 80, 79, 26, 79, 97, 0, 74, 65, 63,
|
||||
58, 70, 0, 74, 31, 78, 97, 0, 97, 97,
|
||||
97, 97, 0, 97, 71, 0, 55, 21, 64, 57,
|
||||
57, 0, 97, 0, 50, 54, 57, 60, 51, 54,
|
||||
46, 42, 44, 46, 0, 51, 52, 48, 44, 0,
|
||||
36, 46, 43, 31, 0, 28, 0, 24, 0, 0,
|
||||
97, 39, 43, 47, 34, 51, 55
|
||||
0, 0, 87, 86, 90, 93, 25, 27, 85, 78,
|
||||
77, 76, 26, 76, 93, 0, 71, 62, 60, 55,
|
||||
67, 0, 71, 30, 74, 93, 93, 93, 93, 93,
|
||||
0, 93, 68, 0, 52, 21, 61, 54, 54, 0,
|
||||
93, 0, 47, 51, 54, 57, 48, 51, 43, 39,
|
||||
41, 43, 0, 48, 49, 45, 41, 0, 33, 43,
|
||||
40, 30, 0, 27, 0, 25, 0, 0, 93, 38,
|
||||
42, 33, 46, 50
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_def[78] =
|
||||
static yyconst flex_int16_t yy_def[75] =
|
||||
{ 0,
|
||||
71, 1, 72, 72, 71, 71, 71, 71, 73, 74,
|
||||
71, 71, 71, 71, 71, 71, 75, 75, 75, 75,
|
||||
75, 75, 76, 71, 71, 73, 71, 74, 71, 71,
|
||||
71, 71, 77, 71, 71, 75, 75, 75, 75, 75,
|
||||
75, 76, 71, 77, 75, 75, 75, 75, 75, 75,
|
||||
75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
|
||||
75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
|
||||
0, 71, 71, 71, 71, 71, 71
|
||||
69, 1, 70, 70, 69, 69, 69, 69, 71, 69,
|
||||
69, 69, 69, 69, 69, 72, 72, 72, 72, 72,
|
||||
72, 73, 69, 69, 71, 69, 69, 69, 69, 69,
|
||||
74, 69, 69, 72, 72, 72, 72, 72, 72, 73,
|
||||
69, 74, 72, 72, 72, 72, 72, 72, 72, 72,
|
||||
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
|
||||
72, 72, 72, 72, 72, 72, 72, 72, 0, 69,
|
||||
69, 69, 69, 69
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_nxt[125] =
|
||||
static yyconst flex_int16_t yy_nxt[120] =
|
||||
{ 0,
|
||||
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 17, 17, 17, 17, 17, 19, 17,
|
||||
20, 21, 22, 17, 17, 17, 17, 25, 25, 25,
|
||||
25, 32, 25, 25, 33, 46, 34, 36, 47, 23,
|
||||
23, 23, 23, 26, 26, 26, 26, 28, 70, 28,
|
||||
28, 42, 42, 69, 42, 44, 68, 44, 44, 67,
|
||||
66, 65, 64, 63, 62, 61, 60, 59, 58, 57,
|
||||
56, 55, 54, 53, 52, 51, 50, 49, 48, 45,
|
||||
35, 27, 43, 41, 40, 39, 38, 37, 35, 31,
|
||||
30, 29, 27, 71, 24, 24, 5, 71, 71, 71,
|
||||
16, 17, 16, 16, 16, 16, 16, 18, 16, 19,
|
||||
20, 21, 16, 16, 16, 16, 24, 24, 24, 24,
|
||||
30, 24, 24, 31, 44, 32, 34, 45, 22, 22,
|
||||
22, 22, 25, 25, 25, 25, 40, 40, 68, 40,
|
||||
42, 67, 42, 42, 66, 65, 64, 63, 62, 61,
|
||||
60, 59, 58, 57, 56, 55, 54, 53, 52, 51,
|
||||
50, 49, 48, 47, 46, 43, 33, 26, 41, 39,
|
||||
38, 37, 36, 35, 33, 29, 28, 27, 26, 69,
|
||||
23, 23, 5, 69, 69, 69, 69, 69, 69, 69,
|
||||
|
||||
71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
|
||||
71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
|
||||
71, 71, 71, 71
|
||||
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
|
||||
69, 69, 69, 69, 69, 69, 69, 69, 69
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_chk[125] =
|
||||
static yyconst flex_int16_t yy_chk[120] =
|
||||
{ 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 7, 7, 8,
|
||||
8, 14, 25, 25, 14, 38, 14, 75, 38, 72,
|
||||
72, 72, 72, 73, 73, 73, 73, 74, 68, 74,
|
||||
74, 76, 76, 66, 76, 77, 64, 77, 77, 63,
|
||||
62, 61, 59, 58, 57, 56, 54, 53, 52, 51,
|
||||
50, 49, 48, 47, 46, 45, 41, 40, 39, 37,
|
||||
35, 26, 24, 22, 21, 20, 19, 18, 15, 13,
|
||||
12, 11, 9, 5, 4, 3, 71, 71, 71, 71,
|
||||
1, 1, 1, 1, 1, 1, 7, 7, 8, 8,
|
||||
13, 24, 24, 13, 36, 13, 72, 36, 70, 70,
|
||||
70, 70, 71, 71, 71, 71, 73, 73, 66, 73,
|
||||
74, 64, 74, 74, 62, 61, 60, 59, 57, 56,
|
||||
55, 54, 52, 51, 50, 49, 48, 47, 46, 45,
|
||||
44, 43, 39, 38, 37, 35, 33, 25, 23, 21,
|
||||
20, 19, 18, 17, 14, 12, 11, 10, 9, 5,
|
||||
4, 3, 69, 69, 69, 69, 69, 69, 69, 69,
|
||||
|
||||
71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
|
||||
71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
|
||||
71, 71, 71, 71
|
||||
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
|
||||
69, 69, 69, 69, 69, 69, 69, 69, 69
|
||||
} ;
|
||||
|
||||
/* Table of booleans, true if rule could match eol. */
|
||||
static yyconst flex_int32_t yy_rule_can_match_eol[24] =
|
||||
static yyconst flex_int32_t yy_rule_can_match_eol[23] =
|
||||
{ 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
||||
0, 1, 0, 0, };
|
||||
1, 0, 0, };
|
||||
|
||||
/* The intent behind this definition is that it'll catch
|
||||
* any uses of REJECT which flex missed.
|
||||
|
@ -546,7 +543,7 @@ do { \
|
|||
} while (0)
|
||||
#define YY_NO_UNISTD_H 1
|
||||
|
||||
#line 550 "config_lexer.cc"
|
||||
#line 547 "config_lexer.cc"
|
||||
|
||||
#define INITIAL 0
|
||||
#define IN_C_COMMENT 1
|
||||
|
@ -795,7 +792,7 @@ YY_DECL
|
|||
|
||||
#line 49 "config_lexer.ll"
|
||||
|
||||
#line 799 "config_lexer.cc"
|
||||
#line 796 "config_lexer.cc"
|
||||
|
||||
yylval = yylval_param;
|
||||
|
||||
|
@ -852,13 +849,13 @@ yy_match:
|
|||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 72 )
|
||||
if ( yy_current_state >= 70 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
while ( yy_current_state != 71 );
|
||||
while ( yy_current_state != 69 );
|
||||
yy_cp = yyg->yy_last_accepting_cpos;
|
||||
yy_current_state = yyg->yy_last_accepting_state;
|
||||
|
||||
|
@ -992,27 +989,22 @@ YY_RULE_SETUP
|
|||
/* ignore C++-style comments */
|
||||
YY_BREAK
|
||||
case 20:
|
||||
/* rule 20 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 76 "config_lexer.ll"
|
||||
/* ignore shell-style comments */
|
||||
/* ignore whitespace */
|
||||
YY_BREAK
|
||||
case 21:
|
||||
/* rule 21 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 77 "config_lexer.ll"
|
||||
/* ignore whitespace */
|
||||
#line 78 "config_lexer.ll"
|
||||
return yytext[0];
|
||||
YY_BREAK
|
||||
case 22:
|
||||
YY_RULE_SETUP
|
||||
#line 79 "config_lexer.ll"
|
||||
return yytext[0];
|
||||
YY_BREAK
|
||||
case 23:
|
||||
YY_RULE_SETUP
|
||||
#line 80 "config_lexer.ll"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 1016 "config_lexer.cc"
|
||||
#line 1008 "config_lexer.cc"
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
case YY_STATE_EOF(IN_C_COMMENT):
|
||||
yyterminate();
|
||||
|
@ -1308,7 +1300,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
|
|||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 72 )
|
||||
if ( yy_current_state >= 70 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
|
@ -1337,11 +1329,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
|
|||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 72 )
|
||||
if ( yy_current_state >= 70 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_is_jam = (yy_current_state == 71);
|
||||
yy_is_jam = (yy_current_state == 69);
|
||||
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
}
|
||||
|
@ -2200,7 +2192,7 @@ void yyfree (void * ptr , yyscan_t yyscanner)
|
|||
|
||||
#define YYTABLES_NAME "yytables"
|
||||
|
||||
#line 80 "config_lexer.ll"
|
||||
#line 79 "config_lexer.ll"
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ null return T_NULL;
|
|||
}
|
||||
|
||||
\/\/[^\n]+ /* ignore C++-style comments */
|
||||
#[^\n]+ /* ignore shell-style comments */
|
||||
[ \t\n]+ /* ignore whitespace */
|
||||
|
||||
. return yytext[0];
|
||||
|
|
|
@ -78,7 +78,7 @@ vector<ConfigItem::Ptr> ConfigCompiler::CompileFile(const string& path)
|
|||
if (!stream.good())
|
||||
throw invalid_argument("Could not open config file: " + path);
|
||||
|
||||
Application::Log(LogInformation, "dyn", "Compiling config file: " + path);
|
||||
Logger::Write(LogInformation, "dyn", "Compiling config file: " + path);
|
||||
|
||||
return CompileStream(path, &stream);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ void EndpointManager::AddListener(string service)
|
|||
|
||||
stringstream s;
|
||||
s << "Adding new listener: port " << service;
|
||||
Application::Log(LogInformation, "icinga", s.str());
|
||||
Logger::Write(LogInformation, "icinga", s.str());
|
||||
|
||||
JsonRpcServer::Ptr server = boost::make_shared<JsonRpcServer>(m_SSLContext);
|
||||
RegisterServer(server);
|
||||
|
@ -106,7 +106,7 @@ void EndpointManager::AddConnection(string node, string service)
|
|||
{
|
||||
stringstream s;
|
||||
s << "Adding new endpoint: [" << node << "]:" << service;
|
||||
Application::Log(LogInformation, "icinga", s.str());
|
||||
Logger::Write(LogInformation, "icinga", s.str());
|
||||
|
||||
JsonRpcEndpoint::Ptr endpoint = boost::make_shared<JsonRpcEndpoint>();
|
||||
RegisterEndpoint(endpoint);
|
||||
|
@ -132,7 +132,7 @@ void EndpointManager::RegisterServer(JsonRpcServer::Ptr server)
|
|||
*/
|
||||
void EndpointManager::NewClientHandler(const TcpClient::Ptr& client)
|
||||
{
|
||||
Application::Log(LogInformation, "icinga", "Accepted new client from " + client->GetPeerAddress());
|
||||
Logger::Write(LogInformation, "icinga", "Accepted new client from " + client->GetPeerAddress());
|
||||
|
||||
JsonRpcEndpoint::Ptr endpoint = boost::make_shared<JsonRpcEndpoint>();
|
||||
endpoint->SetClient(static_pointer_cast<JsonRpcClient>(client));
|
||||
|
|
|
@ -36,10 +36,13 @@ using namespace icinga;
|
|||
*/
|
||||
int IcingaApplication::Main(const vector<string>& args)
|
||||
{
|
||||
ConsoleLogger::Ptr consoleLogger = boost::make_shared<ConsoleLogger>(LogInformation);
|
||||
Logger::RegisterLogger(consoleLogger);
|
||||
|
||||
#ifdef _WIN32
|
||||
Application::Log(LogInformation, "icinga", "Icinga component loader");
|
||||
Logger::Write(LogInformation, "icinga", "Icinga component loader");
|
||||
#else /* _WIN32 */
|
||||
Application::Log(LogInformation, "icinga", "Icinga component loader (version: " ICINGA_VERSION ")");
|
||||
Logger::Write(LogInformation, "icinga", "Icinga component loader (version: " ICINGA_VERSION ")");
|
||||
#endif /* _WIN32 */
|
||||
|
||||
time(&m_StartTime);
|
||||
|
@ -47,7 +50,7 @@ int IcingaApplication::Main(const vector<string>& args)
|
|||
if (args.size() < 2) {
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Syntax: " << args[0] << " <config-file>";
|
||||
Application::Log(LogInformation, "icinga", msgbuf.str());
|
||||
Logger::Write(LogInformation, "icinga", msgbuf.str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -93,7 +96,7 @@ int IcingaApplication::Main(const vector<string>& args)
|
|||
/* set up SSL context */
|
||||
shared_ptr<X509> cert = Utility::GetX509Certificate(GetCertificateFile());
|
||||
string identity = Utility::GetCertificateCN(cert);
|
||||
Application::Log(LogInformation, "icinga", "My identity: " + identity);
|
||||
Logger::Write(LogInformation, "icinga", "My identity: " + identity);
|
||||
EndpointManager::GetInstance()->SetIdentity(identity);
|
||||
|
||||
shared_ptr<SSL_CTX> sslContext = Utility::MakeSSLContext(GetCertificateFile(), GetCertificateFile(), GetCAFile());
|
||||
|
|
|
@ -109,7 +109,7 @@ void JsonRpcEndpoint::NewMessageHandler(const MessagePart& message)
|
|||
|
||||
void JsonRpcEndpoint::ClientClosedHandler(void)
|
||||
{
|
||||
Application::Log(LogWarning, "jsonrpc", "Lost connection to endpoint: identity=" + GetIdentity());
|
||||
Logger::Write(LogWarning, "jsonrpc", "Lost connection to endpoint: identity=" + GetIdentity());
|
||||
|
||||
// TODO: _only_ clear non-persistent publications/subscriptions
|
||||
// unregister ourselves if no persistent publications/subscriptions are left (use a timer for that, once we have a TTL property for the topics)
|
||||
|
@ -132,7 +132,7 @@ void JsonRpcEndpoint::ClientErrorHandler(const std::exception& ex)
|
|||
stringstream message;
|
||||
message << "Error occured for JSON-RPC socket: Message=" << ex.what();
|
||||
|
||||
Application::Log(LogWarning, "jsonrpc", message.str());
|
||||
Logger::Write(LogWarning, "jsonrpc", message.str());
|
||||
}
|
||||
|
||||
void JsonRpcEndpoint::CertificateValidatedHandler(void)
|
||||
|
|
|
@ -65,7 +65,7 @@ void JsonRpcClient::DataAvailableHandler(void)
|
|||
message = MessagePart(jsonString);
|
||||
OnNewMessage(GetSelf(), message);
|
||||
} catch (const std::exception& ex) {
|
||||
Application::Log(LogCritical, "jsonrpc", "Exception while processing message from JSON-RPC client: " + string(ex.what()));
|
||||
Logger::Write(LogCritical, "jsonrpc", "Exception while processing message from JSON-RPC client: " + string(ex.what()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue