mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-02 03:19:02 +08:00
Fixed thread id bug in async mode by passing thread id in log_msg struct
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
#include "../common.h"
|
||||
#include "./format.h"
|
||||
|
||||
@@ -38,14 +39,16 @@ struct log_msg
|
||||
logger_name(),
|
||||
level(l),
|
||||
time(),
|
||||
thread_id(),
|
||||
raw(),
|
||||
formatted() {}
|
||||
|
||||
|
||||
log_msg(const log_msg& other) :
|
||||
logger_name(other.logger_name),
|
||||
level(other.level),
|
||||
time(other.time)
|
||||
level(other.level),
|
||||
time(other.time),
|
||||
thread_id(other.thread_id)
|
||||
{
|
||||
if (other.raw.size())
|
||||
raw << fmt::BasicStringRef<char>(other.raw.data(), other.raw.size());
|
||||
@@ -57,6 +60,7 @@ struct log_msg
|
||||
logger_name(std::move(other.logger_name)),
|
||||
level(other.level),
|
||||
time(std::move(other.time)),
|
||||
thread_id(other.thread_id),
|
||||
raw(std::move(other.raw)),
|
||||
formatted(std::move(other.formatted))
|
||||
{
|
||||
@@ -71,6 +75,7 @@ struct log_msg
|
||||
logger_name = std::move(other.logger_name);
|
||||
level = other.level;
|
||||
time = std::move(other.time);
|
||||
thread_id = other.thread_id;
|
||||
raw = std::move(other.raw);
|
||||
formatted = std::move(other.formatted);
|
||||
other.clear();
|
||||
@@ -79,7 +84,7 @@ struct log_msg
|
||||
|
||||
void clear()
|
||||
{
|
||||
level = level::off;
|
||||
level = level::off;
|
||||
raw.clear();
|
||||
formatted.clear();
|
||||
}
|
||||
@@ -87,6 +92,7 @@ struct log_msg
|
||||
std::string logger_name;
|
||||
level::level_enum level;
|
||||
log_clock::time_point time;
|
||||
std::thread::id thread_id;
|
||||
fmt::MemoryWriter raw;
|
||||
fmt::MemoryWriter formatted;
|
||||
};
|
||||
|
Reference in New Issue
Block a user