Play-/Source/Log.h

58 lines
897 B
C
Raw Permalink Normal View History

2018-05-25 12:37:18 -04:00
#pragma once
#include <string>
#include <map>
2019-10-16 20:51:11 -04:00
#include "filesystem_def.h"
#include "StdStream.h"
#include "Singleton.h"
#ifndef LOGGING_ENABLED
#ifdef _DEBUG
#define LOGGING_ENABLED 1
#else
#define LOGGING_ENABLED 0
#endif
#endif
#if LOGGING_ENABLED
class CLog : public CSingleton<CLog>
{
public:
2018-04-30 21:01:23 +01:00
CLog();
2018-05-22 20:36:56 -04:00
virtual ~CLog() = default;
2018-04-30 21:01:23 +01:00
void Print(const char*, const char*, ...);
void Warn(const char*, const char*, ...);
private:
typedef std::map<std::string, Framework::CStdStream> LogMapType;
2018-04-30 21:01:23 +01:00
Framework::CStdStream& GetLog(const char*);
2019-10-16 20:51:11 -04:00
fs::path m_logBasePath;
2018-04-30 21:01:23 +01:00
LogMapType m_logs;
2018-05-25 12:37:10 -04:00
bool m_showPrints = false;
};
#else
class CLog
{
public:
static CLog& GetInstance()
{
static CLog instance;
return instance;
}
void Print(const char*, const char*, ...)
{
}
void Warn(const char*, const char*, ...)
{
}
};
#endif