#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;
};
