Editor for papermario-dx mods
at main 36 lines 892 B view raw
1// SPDX-FileCopyrightText: 2017-2026 Hans-Kristian Arntzen 2// SPDX-FileCopyrightText: 2026 Alex Bates <alex@bates64.com> 3// 4// SPDX-License-Identifier: MIT 5// 6// Replacement for Granite's util/logging.cpp that uses a global (not 7// thread-local) LoggingInterface, so the command ring worker thread's 8// messages are also routed through the Rust tracing callback. 9 10#include "logging.hpp" 11#include <atomic> 12 13namespace Util 14{ 15 16static std::atomic<LoggingInterface *> logging_iface{nullptr}; 17 18bool interface_log(const char *tag, const char *fmt, ...) 19{ 20 auto *iface = logging_iface.load(std::memory_order_acquire); 21 if (!iface) 22 return false; 23 24 va_list va; 25 va_start(va, fmt); 26 bool ret = iface->log(tag, fmt, va); 27 va_end(va); 28 return ret; 29} 30 31void set_thread_logging_interface(LoggingInterface *iface) 32{ 33 logging_iface.store(iface, std::memory_order_release); 34} 35 36}