You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1009 B
C++

#pragma once
// STL
#include <string>
#include <memory>
#include "ConcurrentQueue.h"
class CSGLogRecord;
class CSGLogger
{
public:
enum LogLevel
{
LOG_DEBUG = 0,
LOG_INFO,
LOG_ERROR,
LOG_FATAL
};
// ctor
CSGLogger();
virtual ~CSGLogger(void);
//
void SetEnableLogFile(bool bEnable);
void SetLogLevel(const std::string& level);
void LogDebug(const char*, ...);
void LogInfo(const char*, ...);
void LogError(const char*, ...);
void LogFatal(const char*, ...);
std::string GetLogDir();
private:
// methods
CSGLogger(const CSGLogger&);
void AppendToLogQueue(LogLevel level, const std::string& str);
void Destroy();
// attributes
bool m_bLogEnable{ true };
std::unique_ptr<CConcurrentQueue<CSGLogRecord>> m_pLogQ;
std::unique_ptr<CThread> m_pLogThread;
LogLevel m_minLevel;
};