From 8f51dd9513d9f4202da5e8eacc8d3b9a0b4ab408 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Sat, 24 Jun 2023 10:01:54 +0300 Subject: [PATCH] common/logging: Move Log::Entry declaration to a separate header This reduces the load of requiring to include std::chrono in all files which include log.h --- src/common/CMakeLists.txt | 1 + src/common/logging/backend.cpp | 6 +++++- src/common/logging/log.h | 2 ++ src/common/logging/log_entry.h | 28 +++++++++++++++++++++++++++ src/common/logging/text_formatter.cpp | 1 + src/common/logging/types.h | 17 ---------------- 6 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 src/common/logging/log_entry.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index cb5a432dc..e3df8b308 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -84,6 +84,7 @@ add_library(citra_common STATIC logging/filter.h logging/formatter.h logging/log.h + logging/log_entry.h logging/text_formatter.cpp logging/text_formatter.h logging/types.h diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index c835a0d85..a672943fa 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -6,7 +6,9 @@ #include #include #include -#include "common/common_paths.h" + +#include + #ifdef _WIN32 #include // For _SH_DENYWR #include // For OutputDebugStringW @@ -22,12 +24,14 @@ #define CITRA_LINUX_GCC_BACKTRACE #endif +#include "common/common_paths.h" #include "common/file_util.h" #include "common/literals.h" #include "common/settings.h" #include "common/thread.h" #include "common/logging/backend.h" #include "common/logging/log.h" +#include "common/logging/log_entry.h" #include "common/logging/text_formatter.h" #include "common/string_util.h" #include "common/threadsafe_queue.h" diff --git a/src/common/logging/log.h b/src/common/logging/log.h index ab596d08f..59269af3e 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -6,6 +6,8 @@ #include #include +#include + #include "common/logging/formatter.h" #include "common/logging/types.h" diff --git a/src/common/logging/log_entry.h b/src/common/logging/log_entry.h new file mode 100644 index 000000000..dd6f44841 --- /dev/null +++ b/src/common/logging/log_entry.h @@ -0,0 +1,28 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include + +#include "common/logging/types.h" + +namespace Common::Log { + +/** + * A log entry. Log entries are store in a structured format to permit more varied output + * formatting on different frontends, as well as facilitating filtering and aggregation. + */ +struct Entry { + std::chrono::microseconds timestamp; + Class log_class{}; + Level log_level{}; + const char* filename = nullptr; + unsigned int line_num = 0; + std::string function; + std::string message; + bool final_entry = false; +}; + +} // namespace Common::Log diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index 9942dd76b..27ec5164b 100644 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp @@ -15,6 +15,7 @@ #include "common/common_funcs.h" #include "common/logging/filter.h" #include "common/logging/log.h" +#include "common/logging/log_entry.h" #include "common/logging/text_formatter.h" #include "common/string_util.h" diff --git a/src/common/logging/types.h b/src/common/logging/types.h index 8dd0b7444..e8fc3fead 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -4,8 +4,6 @@ #pragma once -#include - #include "common/common_types.h" namespace Common::Log { @@ -105,19 +103,4 @@ enum class Class : u8 { Count ///< Total number of logging classes }; -/** - * A log entry. Log entries are store in a structured format to permit more varied output - * formatting on different frontends, as well as facilitating filtering and aggregation. - */ -struct Entry { - std::chrono::microseconds timestamp; - Class log_class{}; - Level log_level{}; - const char* filename = nullptr; - unsigned int line_num = 0; - std::string function; - std::string message; - bool final_entry = false; -}; - } // namespace Common::Log