1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- // // ******************************************************************
- // // /\ /| @File Logger.h
- // // \ V/ @Brief
- // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
- // // / | @Creation 2024-5-9
- // // / \\ @Modified 2024-5-13
- // // *(__\_\
- // // ******************************************************************
- #pragma once
- #include <iostream>
- #include <fstream>
- #include <mutex>
- #include <filesystem>
- #include <string>
- #include <chrono>
- #include <cstdarg>
- #include <iomanip>
- #include <sstream>
- #include <cstdlib> // 对于std::put_time的tm结构体定义
- #include "../BaseEnums/LogerEnums.h"
- namespace Fs = std::filesystem;
- namespace Protocol
- {
- class Logger
- {
- public:
- Logger();
- static void Log(const std::string& message);
- ~Logger();
- inline static LogLevel LogLevel = LogLevel::All;
- private:
- std::string LogPath_;
- std::string LogFileName_; // The full path and filename of the log file.
- std::ofstream LogFile_;
- static std::mutex InstanceMutex_;
- static Logger Instance_;
- Logger(const Logger&) = delete;
- Logger& operator=(const Logger&) = delete;
- };
-
- void WriteLog(LogLevel level, const char* format, ...);
- }
|