From d90eb49281efcf2db039fbaacccebd4acdc15f7f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 29 Sep 2008 22:37:25 +0200 Subject: Einige Fehler am RemoteLogger behoben --- src/Common/RemoteLogger.cpp | 2 ++ src/Core/RequestHandlers/LogRequestHandler.cpp | 3 ++- src/Net/Packets/LogPacket.cpp | 3 +-- src/Net/Packets/LogPacket.h | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Common/RemoteLogger.cpp b/src/Common/RemoteLogger.cpp index ea471bf..7742ee5 100644 --- a/src/Common/RemoteLogger.cpp +++ b/src/Common/RemoteLogger.cpp @@ -25,6 +25,8 @@ namespace Mad { namespace Common { +std::list RemoteLogger::remoteLoggers; + void RemoteLogger::log(MessageCategory category, MessageLevel level, time_t messageTimestamp, const std::string &message, const std::string &messageSource) { for(std::list::iterator remoteLogger = remoteLoggers.begin(); remoteLogger != remoteLoggers.end(); ++remoteLogger) { diff --git a/src/Core/RequestHandlers/LogRequestHandler.cpp b/src/Core/RequestHandlers/LogRequestHandler.cpp index 1366710..5640159 100644 --- a/src/Core/RequestHandlers/LogRequestHandler.cpp +++ b/src/Core/RequestHandlers/LogRequestHandler.cpp @@ -19,6 +19,7 @@ #include "LogRequestHandler.h" #include +#include #include #include #include @@ -39,7 +40,7 @@ void LogRequestHandler::handlePacket(Net::Connection *connection, const Net::Pac // TODO Require authentication Net::Packets::LogPacket logPacket(packet); - Common::Logger::log(logPacket.getCategory(), logPacket.getLevel(), logPacket.getMessage().c_str()); + Common::RemoteLogger::log(logPacket.getCategory(), logPacket.getLevel(), logPacket.getTimestamp(), logPacket.getMessage().c_str(), std::string()); connection->send(Net::Packet(Net::Packet::OK, packet.getRequestId())); diff --git a/src/Net/Packets/LogPacket.cpp b/src/Net/Packets/LogPacket.cpp index fbe59cd..1d6ee88 100644 --- a/src/Net/Packets/LogPacket.cpp +++ b/src/Net/Packets/LogPacket.cpp @@ -18,7 +18,6 @@ */ #include "LogPacket.h" -#include namespace Mad { namespace Net { @@ -32,7 +31,7 @@ LogPacket::LogPacket(Type type, uint16_t requestId, Common::Logger::MessageCateg logData->category = htons(category); logData->level = htons(level); - logData->messageTimestamp = htons(messageTimestamp); + logData->messageTimestamp = htonl(messageTimestamp); std::memcpy(logData->message, message.c_str(), message.length()); } diff --git a/src/Net/Packets/LogPacket.h b/src/Net/Packets/LogPacket.h index dd406b4..040f21a 100644 --- a/src/Net/Packets/LogPacket.h +++ b/src/Net/Packets/LogPacket.h @@ -69,6 +69,10 @@ class LogPacket : public Packet { return (Common::Logger::MessageLevel)ntohs(logData->level); } + time_t getTimestamp() const { + return (time_t)ntohl(logData->messageTimestamp); + } + std::string getMessage() const { return std::string((char*)logData->message, getLength()-sizeof(LogData)); } -- cgit v1.2.3