日志消息類編寫
由于上篇的代碼比較簡單,今天就多寫兩段代碼順便把日志消息類編寫完成。
這個類的實現就是:什么時間,哪個線程,哪個文件的哪一行,發生了什么等級的日志,日志機器名字是什么,日志的消息
總結下來就是 time, thread, file, line, level, name, msg
代碼實現如下:
#include "loglevel.hpp"
#include "utils.hpp"
#include <iostream>
#include <string>
#include <thread>struct LogMsg
{std::string _time;std::thread _id;std::string _file;size_t _line;LogLevel::Level _level;std::string _name;std::string _msg;LogMsg(std::string file, size_t line, LogLevel::Level level, std::string name, std::string msg) : _time(Time::getTime()), _id(std::this_thread::get_id()), _file(file), _line(line), _level(level), _name(name), _msg(msg) {}/* data */
};
日志消息類也就編寫完成了