IXCobraMetricsThreadedPublisher.cpp uses a lambda to log instead of std::cerr

This commit is contained in:
Benjamin Sergeant
2019-05-08 18:53:09 -07:00
parent d53c9c5ecf
commit 232aa069d2
5 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,14 @@
#include "ixcore/utils/IXCoreLogger.h"
namespace ix
{
// Default do nothing logger
IXCoreLogger::LogFunc IXCoreLogger::_currentLogger = [](const char* msg){};
void IXCoreLogger::Log(const char* msg)
{
_currentLogger(msg);
}
} // ix

View File

@ -0,0 +1,22 @@
#pragma once
#include <functional>
namespace ix
{
class IXCoreLogger
{
public:
using LogFunc = std::function<void(const char*)>;
static void Log(const char* msg);
static void setLogFunction(LogFunc& func) {
_currentLogger = func;
}
private:
static LogFunc _currentLogger;
};
} // ix