Change log message identifier for libremote.

Refs #6346
This commit is contained in:
Michael Friedrich 2014-05-28 13:58:56 +02:00
parent 5b071f9611
commit 340693fb34
3 changed files with 23 additions and 23 deletions

View File

@ -75,8 +75,8 @@ void ApiClient::SendMessage(const Dictionary::Ptr& message)
std::ostringstream info, debug;
info << "Error while sending JSON-RPC message for identity '" << m_Identity << "'";
debug << info.str() << std::endl << DiagnosticInformation(ex);
Log(LogWarning, "remote", info.str());
Log(LogDebug, "remote", debug.str());
Log(LogWarning, "ApiClient", info.str());
Log(LogDebug, "ApiClient", debug.str());
Disconnect();
}
@ -84,7 +84,7 @@ void ApiClient::SendMessage(const Dictionary::Ptr& message)
void ApiClient::Disconnect(void)
{
Log(LogWarning, "remote", "API client disconnected for identity '" + m_Identity + "'");
Log(LogWarning, "ApiClient", "API client disconnected for identity '" + m_Identity + "'");
m_Stream->Close();
if (m_Endpoint)
@ -127,7 +127,7 @@ bool ApiClient::ProcessMessage(void)
String method = message->Get("method");
Log(LogNotice, "remote", "Received '" + method + "' message from '" + m_Identity + "'");
Log(LogNotice, "ApiClient", "Received '" + method + "' message from '" + m_Identity + "'");
Dictionary::Ptr resultMessage = make_shared<Dictionary>();
@ -161,7 +161,7 @@ void ApiClient::MessageThreadProc(void)
Disconnect();
} catch (const std::exception& ex) {
Log(LogWarning, "remote", "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));
}
}

View File

@ -72,7 +72,7 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio
configChange = true;
String path = configDir + "/" + kv.first;
Log(LogInformation, "remote", "Updating configuration file: " + path);
Log(LogInformation, "ApiListener", "Updating configuration file: " + path);
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::trunc);
fp << kv.second;
@ -101,7 +101,7 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio
void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const
{
Log(LogInformation, "remote", "Syncing zone: " + zone->GetName());
Log(LogInformation, "ApiListener", "Syncing zone: " + zone->GetName());
String newDir = Application::GetZonesDir() + "/" + zone->GetName();
String oldDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones/" + zone->GetName();
@ -187,7 +187,7 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin& origin, const Dictio
Zone::Ptr zone = Zone::GetByName(kv.first);
if (!zone) {
Log(LogWarning, "remote", "Ignoring config update for unknown zone: " + kv.first);
Log(LogWarning, "ApiListener", "Ignoring config update for unknown zone: " + kv.first);
continue;
}
@ -212,7 +212,7 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin& origin, const Dictio
}
if (configChange) {
Log(LogInformation, "remote", "Restarting after configuration change.");
Log(LogInformation, "ApiListener", "Restarting after configuration change.");
Application::RequestRestart();
}

View File

@ -44,7 +44,7 @@ void ApiListener::OnConfigLoaded(void)
/* set up SSL context */
shared_ptr<X509> cert = GetX509Certificate(GetCertPath());
SetIdentity(GetCertificateCN(cert));
Log(LogInformation, "remote", "My API identity: " + GetIdentity());
Log(LogInformation, "ApiListener", "My API identity: " + GetIdentity());
m_SSLContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath());
@ -133,7 +133,7 @@ void ApiListener::AddListener(const String& service)
std::ostringstream s;
s << "Adding new listener: port " << service;
Log(LogInformation, "remote", s.str());
Log(LogInformation, "ApiListener", s.str());
TcpSocket::Ptr server = make_shared<TcpSocket>();
server->Bind(service, AF_INET6);
@ -184,7 +184,7 @@ void ApiListener::AddConnection(const String& node, const String& service)
info << "Cannot connect to host '" << node << "' on port '" << service << "'";
debug << info.str() << std::endl << DiagnosticInformation(ex);
Log(LogCritical, "remote", info.str());
Log(LogDebug, "remote", debug.str());
Log(LogDebug, "ApiListener", debug.str());
}
}
@ -209,7 +209,7 @@ void ApiListener::NewClientHandler(const Socket::Ptr& client, ConnectionRole rol
shared_ptr<X509> cert = tlsStream->GetPeerCertificate();
String identity = GetCertificateCN(cert);
Log(LogInformation, "remote", "New client connection for identity '" + identity + "'");
Log(LogInformation, "ApiListener", "New client connection for identity '" + identity + "'");
Endpoint::Ptr endpoint = Endpoint::GetByName(identity);
@ -265,7 +265,7 @@ void ApiListener::ApiTimerHandler(void)
if (!need) {
String path = GetApiDir() + "log/" + Convert::ToString(ts);
Log(LogNotice, "remote", "Removing old log file: " + path);
Log(LogNotice, "ApiListener", "Removing old log file: " + path);
(void)unlink(path.CStr());
}
}
@ -325,18 +325,18 @@ void ApiListener::ApiTimerHandler(void)
BOOST_FOREACH(const ApiClient::Ptr& client, endpoint->GetClients())
client->SendMessage(lmessage);
Log(LogNotice, "remote", "Setting log position for identity '" + endpoint->GetName() + "': " +
Log(LogNotice, "ApiListener", "Setting log position for identity '" + endpoint->GetName() + "': " +
Utility::FormatDateTime("%Y/%m/%d %H:%M:%S", ts));
}
Log(LogNotice, "remote", "Current zone master: " + GetMaster()->GetName());
Log(LogNotice, "ApiListener", "Current zone master: " + GetMaster()->GetName());
std::vector<String> names;
BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>())
if (endpoint->IsConnected())
names.push_back(endpoint->GetName() + " (" + Convert::ToString(endpoint->GetClients().size()) + ")");
Log(LogNotice, "remote", "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)
@ -374,7 +374,7 @@ void ApiListener::SyncRelayMessage(const MessageOrigin& origin, const DynamicObj
double ts = Utility::GetTime();
message->Set("ts", ts);
Log(LogNotice, "remote", "Relaying '" + message->Get("method") + "' message");
Log(LogNotice, "ApiListener", "Relaying '" + message->Get("method") + "' message");
if (log)
m_LogQueue.Enqueue(boost::bind(&ApiListener::PersistMessage, this, message));
@ -437,7 +437,7 @@ void ApiListener::SyncRelayMessage(const MessageOrigin& origin, const DynamicObj
ObjectLock olock(endpoint);
if (!endpoint->GetSyncing()) {
Log(LogNotice, "remote", "Sending message to '" + endpoint->GetName() + "'");
Log(LogNotice, "ApiListener", "Sending message to '" + endpoint->GetName() + "'");
BOOST_FOREACH(const ApiClient::Ptr& client, endpoint->GetClients())
client->SendMessage(message);
@ -462,7 +462,7 @@ void ApiListener::OpenLogFile(void)
std::fstream *fp = new std::fstream(path.CStr(), std::fstream::out | std::ofstream::app);
if (!fp->good()) {
Log(LogWarning, "cluster", "Could not open spool file: " + path);
Log(LogWarning, "ApiListener", "Could not open spool file: " + path);
return;
}
@ -545,7 +545,7 @@ void ApiListener::ReplayLog(const ApiClient::Ptr& client)
if (ts < peer_ts)
continue;
Log(LogNotice, "remote", "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);
@ -560,7 +560,7 @@ void ApiListener::ReplayLog(const ApiClient::Ptr& client)
pmessage = JsonDeserialize(message);
} catch (const std::exception&) {
Log(LogWarning, "remote", "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;
@ -578,7 +578,7 @@ void ApiListener::ReplayLog(const ApiClient::Ptr& client)
logStream->Close();
}
Log(LogNotice, "remote", "Replayed " + Convert::ToString(count) + " messages.");
Log(LogNotice, "ApiListener", "Replayed " + Convert::ToString(count) + " messages.");
if (last_sync) {
{