gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

logging.cpp (795B)


      1 #include "logging.h"
      2 
      3 #include <iostream>
      4 
      5 #include <cstdint>
      6 
      7 namespace networkLib
      8 {
      9 	constexpr const char* g_logLevelNames[] =
     10 	{
     11 		"Debug",
     12 		"INFO",
     13 		"WARNING",
     14 		"ERROR"
     15 	};
     16 
     17 	static_assert(std::size(g_logLevelNames) == static_cast<uint32_t>(LogLevel::Count));
     18 
     19 	void logStdOut(LogLevel _level, const char* _func, int _line, const std::string& _message)
     20 	{
     21 		std::cout << g_logLevelNames[static_cast<uint32_t>(_level)] << ": " << _func << '@' << _line << ": " << _message << '\n';
     22 	}
     23 
     24 	namespace
     25 	{
     26 		LogFunc g_logFunc = logStdOut;
     27 	}
     28 
     29 	void setLogFunc(const LogFunc& _func)
     30 	{
     31 		if(!_func)
     32 			g_logFunc = logStdOut;
     33 		else
     34 			g_logFunc = _func;
     35 	}
     36 
     37 	void log(LogLevel _level, const char* _func, int _line, const std::string& _message)
     38 	{
     39 		g_logFunc(_level, _func, _line, _message);
     40 	}
     41 }