mirror of
https://github.com/izzy2lost/libultraship.git
synced 2026-06-19 01:16:13 -07:00
Removes ConsoleSink. (#286)
This commit is contained in:
@@ -126,11 +126,6 @@ set(Source_Files__Log
|
||||
|
||||
source_group("Log" FILES ${Source_Files__Log})
|
||||
|
||||
set(Source_Files__Log__SPDLog
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/log/spd/ConsoleSink.h
|
||||
)
|
||||
|
||||
source_group("log/spdLog" FILES ${Source_Files__Log__SPDLog})
|
||||
target_sources(libultraship PRIVATE ${Source_Files__Log} ${Source_Files__Log__SPDLog})
|
||||
|
||||
#=================== Window ===================
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <spdlog/async.h>
|
||||
#include <spdlog/sinks/rotating_file_sink.h>
|
||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||
#include "log/spd/ConsoleSink.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "utils/OSXFolderManager.h"
|
||||
@@ -98,10 +97,6 @@ void Context::InitLogging() {
|
||||
spdlog::init_thread_pool(8192, 1);
|
||||
std::vector<spdlog::sink_ptr> sinks;
|
||||
|
||||
auto consoleSink = std::make_shared<spdlog::sinks::lus_sink_mt>();
|
||||
// consoleSink->set_level(spdlog::level::trace);
|
||||
sinks.push_back(consoleSink);
|
||||
|
||||
#if (!defined(_WIN32) && !defined(__WIIU__)) || defined(_DEBUG)
|
||||
#if defined(_DEBUG) && defined(_WIN32)
|
||||
// LLVM on Windows allocs a hidden console in its entrypoint function.
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <spdlog/details/fmt_helper.h>
|
||||
#include <spdlog/details/null_mutex.h>
|
||||
#include <spdlog/details/os.h>
|
||||
#include <spdlog/sinks/base_sink.h>
|
||||
#include <spdlog/details/synchronous_factory.h>
|
||||
#include "Context.h"
|
||||
#include "window/gui/Gui.h"
|
||||
#include "window/gui/ConsoleWindow.h"
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include "public/bridge/consolevariablebridge.h"
|
||||
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
|
||||
template <typename Mutex> class ConsoleSink final : public base_sink<Mutex> {
|
||||
public:
|
||||
explicit ConsoleSink(std::string tag = "spdlog", bool use_raw_msg = false)
|
||||
: tag_(std::move(tag)), use_raw_msg_(use_raw_msg) {
|
||||
}
|
||||
|
||||
protected:
|
||||
void sink_it_(const details::log_msg& msg) override {
|
||||
if (LUS::Context::GetInstance() == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
memory_buf_t formatted;
|
||||
if (use_raw_msg_) {
|
||||
details::fmt_helper::append_string_view(msg.payload, formatted);
|
||||
} else {
|
||||
base_sink<Mutex>::formatter_->format(msg, formatted);
|
||||
}
|
||||
formatted.push_back('\0');
|
||||
const char* msg_output = formatted.data();
|
||||
if (CVarGetInteger("gSinkEnabled", 0) &&
|
||||
LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")->IsVisible()) {
|
||||
std::reinterpret_pointer_cast<LUS::ConsoleWindow>(
|
||||
LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
|
||||
->Append("Logs", msg.level, "%s", msg_output);
|
||||
}
|
||||
}
|
||||
|
||||
void flush_() override {
|
||||
}
|
||||
|
||||
private:
|
||||
std::string tag_;
|
||||
bool use_raw_msg_;
|
||||
};
|
||||
|
||||
using lus_sink_mt = ConsoleSink<std::mutex>;
|
||||
using lus_sink_st = ConsoleSink<details::null_mutex>;
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
Reference in New Issue
Block a user