mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
NKAI: visual logger
This commit is contained in:
42
lib/logging/VisualLogger.cpp
Normal file
42
lib/logging/VisualLogger.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* CLogger.cpp, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#include "StdInc.h"
|
||||
#include "VisualLogger.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
DLL_LINKAGE VisualLogger * logVisual = new VisualLogger();
|
||||
|
||||
|
||||
void VisualLogger::updateWithLock(std::string channel, std::function<void(IVisualLogBuilder & logBuilder)> func)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
mapLines[channel].clear();
|
||||
|
||||
func(VisualLogBuilder(mapLines[channel]));
|
||||
}
|
||||
|
||||
void VisualLogger::visualize(ILogVisualizer & visulizer)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
for(auto line : mapLines[keyToShow])
|
||||
{
|
||||
visulizer.drawLine(line.start, line.end);
|
||||
}
|
||||
}
|
||||
|
||||
void VisualLogger::setKey(std::string key)
|
||||
{
|
||||
keyToShow = key;
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
Reference in New Issue
Block a user