summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Core/ConnectionManager.cpp9
-rw-r--r--src/Core/ConnectionManager.h2
-rw-r--r--src/Core/RequestHandlers/LogRequestHandler.cpp10
3 files changed, 20 insertions, 1 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index c83f3aa..93d6d3f 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -190,6 +190,15 @@ Net::Connection* ConnectionManager::getDaemonConnection(const std::string &name)
return daemon->second;
}
+std::string ConnectionManager::getDaemonName(const Net::Connection *con) const throw (Common::Exception&) {
+ for(std::map<std::string,Net::ServerConnection*>::const_iterator daemon = identifiedDaemonConnections.begin(); daemon != identifiedDaemonConnections.end(); ++daemon) {
+ if(daemon->second == con)
+ return daemon->first;
+ }
+
+ throw Common::Exception(Common::Exception::UNKNOWN_DAEMON);
+}
+
void ConnectionManager::identifyDaemonConnection(Net::Connection *connection, const std::string &name) throw (Common::Exception&) {
// TODO Logging
diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h
index cd470d9..4f3ff67 100644
--- a/src/Core/ConnectionManager.h
+++ b/src/Core/ConnectionManager.h
@@ -86,6 +86,8 @@ class ConnectionManager {
void run();
Net::Connection* getDaemonConnection(const std::string &name) const throw (Common::Exception&);
+ std::string getDaemonName(const Net::Connection *con) const throw (Common::Exception&);
+
void identifyDaemonConnection(Net::Connection *connection, const std::string &name) throw (Common::Exception&);
std::vector<Common::HostInfo> getDaemonList() const;
};
diff --git a/src/Core/RequestHandlers/LogRequestHandler.cpp b/src/Core/RequestHandlers/LogRequestHandler.cpp
index 5640159..6bda627 100644
--- a/src/Core/RequestHandlers/LogRequestHandler.cpp
+++ b/src/Core/RequestHandlers/LogRequestHandler.cpp
@@ -20,6 +20,7 @@
#include "LogRequestHandler.h"
#include <Common/Logger.h>
#include <Common/RemoteLogger.h>
+#include "../ConnectionManager.h"
#include <Net/Connection.h>
#include <Net/Packets/ErrorPacket.h>
#include <Net/Packets/LogPacket.h>
@@ -40,7 +41,14 @@ void LogRequestHandler::handlePacket(Net::Connection *connection, const Net::Pac
// TODO Require authentication
Net::Packets::LogPacket logPacket(packet);
- Common::RemoteLogger::log(logPacket.getCategory(), logPacket.getLevel(), logPacket.getTimestamp(), logPacket.getMessage().c_str(), std::string());
+
+ try {
+ Common::RemoteLogger::log(logPacket.getCategory(), logPacket.getLevel(), logPacket.getTimestamp(), logPacket.getMessage().c_str(),
+ ConnectionManager::getConnectionManager()->getDaemonName(connection));
+ }
+ catch(Common::Exception &e) {
+ Common::Logger::logf(Common::Logger::ERROR, "Can't determine daemon name: %s", e.strerror().c_str());
+ }
connection->send(Net::Packet(Net::Packet::OK, packet.getRequestId()));