logging: Address some issues

This commit is contained in:
GPUCode 2023-06-24 18:30:13 +03:00
parent 9c3e2d0f50
commit ba98bf058a
11 changed files with 19 additions and 34 deletions

View File

@ -180,12 +180,6 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK)
return JNI_ERR;
// Initialize Logger
Log::Filter log_filter;
log_filter.ParseFilterString(Settings::values.log_filter.GetValue());
Log::SetGlobalFilter(log_filter);
Log::AddBackend(std::make_unique<Log::LogcatBackend>());
// Initialize misc classes
s_savestate_info_class = reinterpret_cast<jclass>(
env->NewGlobalRef(env->FindClass("org/citra/citra_emu/NativeLibrary$SavestateInfo")));

View File

@ -438,10 +438,8 @@ void Java_org_citra_citra_1emu_NativeLibrary_CreateConfigFile(JNIEnv* env,
void Java_org_citra_citra_1emu_NativeLibrary_CreateLogFile(JNIEnv* env,
[[maybe_unused]] jclass clazz) {
Log::RemoveBackend(Log::FileBackend::Name());
FileUtil::CreateFullPath(FileUtil::GetUserPath(FileUtil::UserPath::LogDir));
Log::AddBackend(std::make_unique<Log::FileBackend>(
FileUtil::GetUserPath(FileUtil::UserPath::LogDir) + LOG_FILE));
Common::Log::Initialize();
Common::Log::Start();
LOG_INFO(Frontend, "Logging backend initialised");
}

View File

@ -330,7 +330,6 @@ int main(int argc, char** argv) {
return -1;
}
Core::System::InitializeGlobalInstance();
auto& system = Core::System::GetInstance();
auto& movie = Core::Movie::GetInstance();

View File

@ -2880,7 +2880,6 @@ int main(int argc, char* argv[]) {
// generating shaders
setlocale(LC_ALL, "C");
Core::System::InitializeGlobalInstance();
auto& system{Core::System::GetInstance()};
GMainWindow main_window(system);

View File

@ -7,6 +7,7 @@
#include <atomic>
#include <condition_variable>
#include <cstddef>
#include <memory>
#include <mutex>
#include <new>
@ -94,7 +95,7 @@ private:
const size_t pos = write_index % Capacity;
// Emplace into the queue.
std::construct_at(std::addressof(m_data[pos]), std::forward<Args>(args)...);
new (std::addressof(m_data[pos])) T(std::forward<Args>(args)...);
// Increment the write index.
++m_write_index;

View File

@ -8,9 +8,9 @@
#include <memory>
#include <sstream>
#include <unordered_map>
#include <fmt/format.h>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <fmt/format.h>
#include "common/assert.h"
#include "common/common_funcs.h"
#include "common/common_paths.h"

View File

@ -352,6 +352,9 @@ private:
lambda(static_cast<Backend&>(debugger_backend));
lambda(static_cast<Backend&>(color_console_backend));
lambda(static_cast<Backend&>(file_backend));
#ifdef ANDROID
lambda(static_cast<Backend&>(lc_backend));
#endif
}
static void Deleter(Impl* ptr) {
@ -394,6 +397,9 @@ private:
DebuggerBackend debugger_backend{};
ColorConsoleBackend color_console_backend{};
FileBackend file_backend;
#ifdef ANDROID
LogcatBackend lc_backend{};
#endif
MPSCQueue<Entry> message_queue{};
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};

View File

@ -5,7 +5,7 @@
#pragma once
#include <type_traits>
#include <fmt/core.h>
#include <fmt/format.h>
// adapted from https://github.com/fmtlib/fmt/issues/2704
// a generic formatter for enum classes

View File

@ -52,6 +52,8 @@
namespace Core {
/*static*/ System System::s_instance;
template <>
Core::System& Global() {
return System::GetInstance();
@ -69,20 +71,6 @@ Core::Timing& Global() {
System::~System() = default;
System& System::GetInstance() {
if (!s_instance) {
throw std::runtime_error("Using System instance before its initialization");
}
return *s_instance;
}
void System::InitializeGlobalInstance() {
if (s_instance) {
throw std::runtime_error("Reinitializing Global System instance.");
}
s_instance = std::unique_ptr<System>(new System);
}
System::ResultStatus System::RunLoop(bool tight_loop) {
status = ResultStatus::Success;
if (!IsPoweredOn()) {

View File

@ -73,9 +73,9 @@ public:
* Gets the instance of the System singleton class.
* @returns Reference to the instance of the System singleton class.
*/
[[nodiscard]] static System& GetInstance();
static void InitializeGlobalInstance();
[[nodiscard]] static System& GetInstance() {
return s_instance;
}
/// Enumeration representing the return values of the System Initialize and Load process.
enum class ResultStatus : u32 {
@ -392,7 +392,7 @@ private:
std::unique_ptr<Core::ExclusiveMonitor> exclusive_monitor;
private:
inline static std::unique_ptr<System> s_instance;
static System s_instance;
std::atomic_bool is_powered_on{};

View File

@ -8,7 +8,7 @@ add_executable(citra-room
create_target_directory_groups(citra-room)
target_link_libraries(citra-room PRIVATE citra_common network)
target_link_libraries(citra-room PRIVATE citra_common citra_core network)
if (ENABLE_WEB_SERVICE)
target_compile_definitions(citra-room PRIVATE -DENABLE_WEB_SERVICE)
target_link_libraries(citra-room PRIVATE web_service)