1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- // // ******************************************************************
- // // /\ /| @File Loger.h
- // // \ V/ @Brief
- // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
- // // / | @Creation 2024-05-16
- // // / \\ @Modified 2024-06-24
- // // *(__\_\
- // // ******************************************************************
- #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/loger_enums.h"
- namespace Fs = std::filesystem;
- namespace Protocol
- {
- class Loger
- {
- public:
- Loger();
- static void Log(const std::string& message);
- ~Loger();
- inline static auto 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 Loger instance_;
- Loger(const Loger&) = delete;
- Loger& operator=(const Loger&) = delete;
- };
- void WriteLog(LogLevel level, const char* format, ...);
- }
|