mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Logging cleanup (server).
This commit is contained in:
parent
046e1a7c29
commit
a8a3230798
@ -278,7 +278,9 @@ void CConnection::enableSmartVectorMemberSerializatoin()
|
||||
CSerializer::smartVectorMembersSerialization = true;
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream &str, const CConnection &cpc)
|
||||
{
|
||||
return str << "Connection with " << cpc.name << " (ID: " << cpc.connectionID << /*", " << (cpc.host ? "host" : "guest") <<*/ ")";
|
||||
}
|
||||
std::string CConnection::toString() const
|
||||
{
|
||||
boost::format fmt("Connection with %s (ID: %d)");
|
||||
fmt % name % connectionID;
|
||||
return fmt.str();
|
||||
}
|
||||
|
@ -90,6 +90,8 @@ public:
|
||||
void prepareForSendingHeroes(); //disables sending vectorized, enables smart pointer serialization, clears saved/loaded ptr cache
|
||||
void enterPregameConnectionMode();
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
template<class T>
|
||||
CConnection & operator>>(T &t)
|
||||
{
|
||||
@ -104,5 +106,3 @@ public:
|
||||
return * this;
|
||||
}
|
||||
};
|
||||
|
||||
DLL_LINKAGE std::ostream &operator<<(std::ostream &str, const CConnection &cpc);
|
||||
|
@ -78,7 +78,7 @@ void CPregameServer::handleConnection(CConnection *cpc)
|
||||
CPackForSelectionScreen *cpfs = nullptr;
|
||||
*cpc >> cpfs;
|
||||
|
||||
logNetwork->infoStream() << "Got package to announce " << typeid(*cpfs).name() << " from " << *cpc;
|
||||
logNetwork->info("Got package to announce %s from %s", typeid(*cpfs).name(), cpc->toString());
|
||||
|
||||
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
|
||||
bool quitting = dynamic_ptr_cast<QuitMenuWithoutStarting>(cpfs),
|
||||
@ -110,7 +110,7 @@ void CPregameServer::handleConnection(CConnection *cpc)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
|
||||
logNetwork->errorStream() << *cpc << " dies... \nWhat happened: " << e.what();
|
||||
logNetwork->error("%s dies... \nWhat happened: %s", cpc->toString(), e.what());
|
||||
}
|
||||
|
||||
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
|
||||
@ -132,7 +132,7 @@ void CPregameServer::handleConnection(CConnection *cpc)
|
||||
}
|
||||
}
|
||||
|
||||
logNetwork->infoStream() << "Thread listening for " << *cpc << " ended";
|
||||
logNetwork->info("Thread listening for %s ended", cpc->toString());
|
||||
listeningThreads--;
|
||||
vstd::clear_pointer(cpc->handler);
|
||||
}
|
||||
@ -262,7 +262,7 @@ void CPregameServer::sendPack(CConnection * pc, const CPackForSelectionScreen &
|
||||
{
|
||||
if(!pc->sendStop)
|
||||
{
|
||||
logNetwork->infoStream() << "\tSending pack of type " << typeid(pack).name() << " to " << *pc;
|
||||
logNetwork->info("\tSending pack of type %s to %s", typeid(pack).name(), pc->toString());
|
||||
*pc << &pack;
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ void CVCMIServer::start()
|
||||
acc.join();
|
||||
if (error)
|
||||
{
|
||||
logNetwork->warnStream()<<"Got connection but there is an error " << error;
|
||||
logNetwork->warn("Got connection but there is an error %s", error.message());
|
||||
return;
|
||||
}
|
||||
logNetwork->info("We've accepted someone... ");
|
||||
|
Loading…
Reference in New Issue
Block a user