refactoring log class
This commit is contained in:
parent
ca291b6573
commit
04e9366cb8
|
@ -30,10 +30,10 @@ add_executable(shadps4
|
|||
src/Core/PS4/Loader/Elf.h
|
||||
src/GUI/ElfViewer.cpp
|
||||
src/GUI/ElfViewer.h
|
||||
src/Util/Log.h
|
||||
src/Util/Log.cpp
|
||||
"src/Core/virtual_memory.cpp"
|
||||
"src/Core/virtual_memory.h"
|
||||
src/Util/log.h
|
||||
src/Util/log.cpp
|
||||
src/Core/virtual_memory.cpp
|
||||
src/Core/virtual_memory.h
|
||||
src/Core/PS4/Linker.cpp
|
||||
src/Core/PS4/Linker.h
|
||||
src/Lib/Threads.cpp
|
||||
|
@ -46,6 +46,8 @@ add_executable(shadps4
|
|||
src/Core/PS4/HLE/Graphics/video_out.h
|
||||
src/discord.h
|
||||
src/discord.cpp
|
||||
src/Core/PS4/HLE/Kernel/event_queues.cpp
|
||||
src/Core/PS4/HLE/Kernel/event_queues.h
|
||||
"src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceVideoOut.cpp" "src/Core/PS4/HLE/LibSceVideoOut.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h")
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "video_out.h"
|
||||
|
||||
#include <Core/PS4/HLE/Libs.h>
|
||||
#include <Util/Log.h>
|
||||
#include <Util/log.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <magic_enum.hpp>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
|
||||
namespace HLE::Libs::LibKernel::EventQueues {};
|
|
@ -7,7 +7,7 @@
|
|||
#include <bit>
|
||||
#include <magic_enum.hpp>
|
||||
|
||||
#include "../../../../Util/Log.h"
|
||||
#include <Util/log.h>
|
||||
#include "../../../../Util/Singleton.h"
|
||||
#include "../ErrorCodes.h"
|
||||
#include "../Libs.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "LibKernel.h"
|
||||
#include "Libs.h"
|
||||
#include <debug.h>
|
||||
#include "../../../Util/Log.h"
|
||||
#include <Util/log.h>
|
||||
#include "Kernel/memory_management.h"
|
||||
#include "../../../Util/Singleton.h"
|
||||
#include "Kernel/Objects/physical_memory.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Linker.h"
|
||||
#include "../virtual_memory.h"
|
||||
#include "../../Util/Log.h"
|
||||
#include <Util/log.h>
|
||||
#include "../../Util/Disassembler.h"
|
||||
#include <Util/string_util.h>
|
||||
#include "Util/aerolib.h"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <spdlog/pattern_formatter.h>
|
||||
#include <magic_enum.hpp>
|
||||
#include <fmt/core.h>
|
||||
#include "../../../Util/Log.h"
|
||||
#include <Util/log.h>
|
||||
|
||||
#ifdef _WIN64
|
||||
#define DBG_BREAKPOINT __debugbreak();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "../../../types.h"
|
||||
#include "SymbolsResolver.h"
|
||||
#include "../../../Util/Log.h"
|
||||
#include <Util/log.h>
|
||||
|
||||
|
||||
void SymbolsResolver::AddSymbol(const SymbolRes& s, u64 virtual_addr)
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include <vector>
|
||||
#include <spdlog/common.h>
|
||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||
|
||||
|
||||
|
||||
namespace logging {
|
||||
std::vector<spdlog::sink_ptr> sinks;
|
||||
|
||||
int init(bool use_stdout) {
|
||||
sinks.clear();//clear existing sinks
|
||||
if (use_stdout)//if we use stdout window then init it as well
|
||||
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());
|
||||
|
||||
return 0;//all ok
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
#pragma once
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
namespace logging {
|
||||
|
||||
#define LOG_TRACE SPDLOG_TRACE
|
||||
#define LOG_DEBUG SPDLOG_DEBUG
|
||||
#define LOG_INFO SPDLOG_INFO
|
||||
#define LOG_WARN SPDLOG_WARN
|
||||
#define LOG_ERROR SPDLOG_ERROR
|
||||
#define LOG_CRITICAL SPDLOG_CRITICAL
|
||||
|
||||
#define LOG_TRACE_IF(flag, ...) \
|
||||
if (flag) LOG_TRACE(__VA_ARGS__)
|
||||
#define LOG_DEBUG_IF(flag, ...) \
|
||||
if (flag) LOG_DEBUG(__VA_ARGS__)
|
||||
#define LOG_INFO_IF(flag, ...) \
|
||||
if (flag) LOG_INFO(__VA_ARGS__)
|
||||
#define LOG_WARN_IF(flag, ...) \
|
||||
if (flag) LOG_WARN(__VA_ARGS__)
|
||||
#define LOG_ERROR_IF(flag, ...) \
|
||||
if (flag) LOG_ERROR(__VA_ARGS__)
|
||||
#define LOG_CRITICAL_IF(flag, ...) \
|
||||
if (flag) LOG_CRITICAL(__VA_ARGS__)
|
||||
|
||||
int init(bool use_stdout);
|
||||
} // namespace logging
|
||||
|
||||
// copyright vita3k emu https://github.com/Vita3K/Vita3K/blob/master/vita3k/util/include/util/log.h
|
||||
/*
|
||||
returns: A string with the input number formatted in hexadecimal
|
||||
Examples:
|
||||
* `12` returns: `"0xC"`
|
||||
* `1337` returns: `"0x539"`
|
||||
* `72742069` returns: `"0x455F4B5"`
|
||||
*/
|
||||
template <typename T>
|
||||
std::string log_hex(T val) {
|
||||
using unsigned_type = typename std::make_unsigned<T>::type;
|
||||
std::stringstream ss;
|
||||
ss << "0x";
|
||||
ss << std::hex << static_cast<unsigned_type>(val);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/*
|
||||
returns: A string with the input number formatted in hexadecimal with padding of the inputted type size
|
||||
Examples:
|
||||
* `uint8_t 5` returns: `"0x05"`
|
||||
* `uint8_t 15` returns: `"0x0F"`
|
||||
* `uint8_t 255` returns: `"0xFF"`
|
||||
|
||||
* `uint16_t 15` returns: `"0x000F"`
|
||||
* `uint16_t 1337` returns: `"0x0539"`
|
||||
* `uint16_t 65535` returns: `"0xFFFF"`
|
||||
|
||||
|
||||
* `uint32_t 15` returns: `"0x0000000F"`
|
||||
* `uint32_t 1337` returns: `"0x00000539"`
|
||||
* `uint32_t 65535` returns: `"0x0000FFFF"`
|
||||
* `uint32_t 134217728` returns: `"0x08000000"`
|
||||
*/
|
||||
template <typename T>
|
||||
std::string log_hex_full(T val) {
|
||||
std::stringstream ss;
|
||||
ss << "0x";
|
||||
ss << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex << val;
|
||||
return ss.str();
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
#include "spdlog/spdlog.h"
|
||||
#include "types.h"
|
||||
#include "GUI/ElfViewer.h"
|
||||
#include "Util/Log.h"
|
||||
#include <Util/log.h>
|
||||
|
||||
// This example can also compile and run with Emscripten! See 'Makefile.emscripten' for details.
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
|
Loading…
Reference in New Issue