|
|
@ -9,13 +9,15 @@
|
|
|
|
#include <wincon.h>
|
|
|
|
#include <wincon.h>
|
|
|
|
// clang-format on
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
#include <spdlog/details/null_mutex.h>
|
|
|
|
#include <spdlog/details/null_mutex.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
|
|
|
|
namespace spdlog {
|
|
|
|
namespace spdlog {
|
|
|
|
namespace sinks {
|
|
|
|
namespace sinks {
|
|
|
|
template <typename Mutex>
|
|
|
|
template <typename Mutex>
|
|
|
|
wincolor_sink<Mutex>::wincolor_sink(void *out_handle, color_mode mode) : out_handle_(out_handle) {
|
|
|
|
wincolor_sink<Mutex>::wincolor_sink(void *out_handle, color_mode mode)
|
|
|
|
|
|
|
|
: out_handle_(out_handle) {
|
|
|
|
set_color_mode_impl(mode);
|
|
|
|
set_color_mode_impl(mode);
|
|
|
|
// set level colors
|
|
|
|
// set level colors
|
|
|
|
colors_.at(level_to_number(level::trace)) =
|
|
|
|
colors_.at(level_to_number(level::trace)) =
|
|
|
@ -74,7 +76,6 @@ void wincolor_sink<Mutex>::flush_() {
|
|
|
|
// windows console always flushed?
|
|
|
|
// windows console always flushed?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename Mutex>
|
|
|
|
template <typename Mutex>
|
|
|
|
void wincolor_sink<Mutex>::set_color_mode(color_mode mode) {
|
|
|
|
void wincolor_sink<Mutex>::set_color_mode(color_mode mode) {
|
|
|
|
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
|
|
|
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
|
|
@ -112,9 +113,7 @@ std::uint16_t wincolor_sink<Mutex>::set_foreground_color_(std::uint16_t attribs)
|
|
|
|
|
|
|
|
|
|
|
|
// print a range of formatted message to console
|
|
|
|
// print a range of formatted message to console
|
|
|
|
template <typename Mutex>
|
|
|
|
template <typename Mutex>
|
|
|
|
void wincolor_sink<Mutex>::print_range_(const memory_buf_t &formatted,
|
|
|
|
void wincolor_sink<Mutex>::print_range_(const memory_buf_t &formatted, size_t start, size_t end) {
|
|
|
|
size_t start,
|
|
|
|
|
|
|
|
size_t end) {
|
|
|
|
|
|
|
|
if (end > start) {
|
|
|
|
if (end > start) {
|
|
|
|
auto size = static_cast<DWORD>(end - start);
|
|
|
|
auto size = static_cast<DWORD>(end - start);
|
|
|
|
auto ignored = ::WriteConsoleA(static_cast<HANDLE>(out_handle_), formatted.data() + start,
|
|
|
|
auto ignored = ::WriteConsoleA(static_cast<HANDLE>(out_handle_), formatted.data() + start,
|
|
|
|