spdlog/include/spdlog/details/log_msg.h

57 lines
1.3 KiB
C
Raw Normal View History

2016-04-20 04:57:49 -04:00
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
2018-04-28 18:43:42 -04:00
#include "spdlog/common.h"
#include "spdlog/details/os.h"
2016-04-20 04:57:49 -04:00
#include <string>
#include <utility>
2018-03-17 06:47:46 -04:00
namespace spdlog {
namespace details {
2016-04-20 04:57:49 -04:00
struct log_msg
{
2018-11-22 11:47:50 -05:00
log_msg(source_loc loc, const std::string *loggers_name, level::level_enum lvl, string_view_t view)
2018-03-09 08:26:33 -05:00
: logger_name(loggers_name)
, level(lvl)
2016-07-08 10:50:13 -04:00
#ifndef SPDLOG_NO_DATETIME
, time(os::now())
2016-07-08 10:50:13 -04:00
#endif
2016-04-20 04:57:49 -04:00
2016-07-08 10:50:13 -04:00
#ifndef SPDLOG_NO_THREAD_ID
, thread_id(os::thread_id())
2018-11-22 11:47:50 -05:00
, source(loc)
, payload(view)
2016-07-08 10:50:13 -04:00
#endif
{
2016-04-20 04:57:49 -04:00
}
2018-11-22 11:49:14 -05:00
log_msg(const std::string *loggers_name, level::level_enum lvl, string_view_t view)
: log_msg(source_loc{}, loggers_name, lvl, view)
{
}
2018-11-22 11:47:50 -05:00
log_msg(const log_msg &other) = default;
2018-10-20 11:27:58 -04:00
log_msg &operator=(const log_msg &other) = default;
2016-04-20 04:57:49 -04:00
2018-03-09 08:26:33 -05:00
const std::string *logger_name{nullptr};
level::level_enum level{level::off};
2016-04-20 04:57:49 -04:00
log_clock::time_point time;
size_t thread_id{0};
2018-10-29 18:54:22 -04:00
size_t msg_id{0};
2018-10-29 18:54:22 -04:00
// wrapping the formatted text with color (updated by pattern_formatter).
2018-06-23 18:32:39 -04:00
mutable size_t color_range_start{0};
mutable size_t color_range_end{0};
2018-11-22 11:47:50 -05:00
source_loc source;
const string_view_t payload;
2016-04-20 04:57:49 -04:00
};
2018-03-17 06:47:46 -04:00
} // namespace details
} // namespace spdlog