4#include <jsoncpp/json/json.h>
10#include <jsoncpp/json/json.h>
11#include "../logs/message.hpp"
35 json[
"msg_mod"] =
"format";
41 static Json::Value
toJson(
const std::string &msg)
44 json[
"unformatted_msg"] = msg;
45 json[
"msg_mod"] =
"unformatted";
54 dmsg.
msg_mod = json[
"msg_mod"].asString();
71 json[
"ctime"] =
static_cast<Json::Int64
>(msg.
_ctime);
72 json[
"line"] = msg.
_line;
73 json[
"tid"] = std::to_string(*(
unsigned long int *)(&msg.
_tid));
75 json[
"file"] = msg.
_file;
86 msg.
_ctime = json[
"ctime"].asInt64();
87 msg.
_line = json[
"line"].asUInt();
88 msg.
_tid = std::thread::id(std::stoul(json[
"tid"].asString()));
90 msg.
_file = json[
"file"].asString();
91 msg.
_logger = json[
"logger"].asString();
92 msg.
_payload = json[
"payload"].asString();
@classCodec
Definition codec.hpp:26
static DeliverMsg fromJson(const Json::Value &json)
将Json信息反序列化为传递消息
Definition codec.hpp:51
static Json::Value toJson(const std::string &msg)
将非结构化信息序列化为Json格式
Definition codec.hpp:41
static LogMsg msgFromJson(const Json::Value &json)
将Json信息反序列化为传递消息
Definition codec.hpp:83
static Json::Value toJson(const LogMsg &msg)
将结构化信息序列化为Json格式
Definition codec.hpp:31
static Json::Value msgToJson(const LogMsg &msg)
将结构化信息序列化为Json格式
Definition codec.hpp:68
static LogLevel::value fromString(const std::string &level)
从字符串转换成日志等级
Definition level.hpp:73
static const char * toString(LogLevel::value level)
将日志等级转换为对应的字符串
Definition level.hpp:44
传递的消息
Definition codec.hpp:18
std::string unformatted_msg
非结构化消息
Definition codec.hpp:20
std::string msg_mod
消息模式
Definition codec.hpp:19
LogMsg format_msg
结构化信息
Definition codec.hpp:21
日志消息结构体
Definition message.hpp:24
size_t _line
行号
Definition message.hpp:26
std::string _payload
有效载荷数据
Definition message.hpp:31
time_t _ctime
日志产生的时间戳
Definition message.hpp:25
std::string _file
源文件名称
Definition message.hpp:29
std::string _logger
日志器
Definition message.hpp:30
std::thread::id _tid
线程ID
Definition message.hpp:27
LogLevel::value _level
日志等级
Definition message.hpp:28