mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-12 13:13:43 +00:00
LogBase class for both SysCallBase and Module
This commit is contained in:
parent
0865fca90a
commit
5c84ad30a1
75
rpcs3/Emu/SysCalls/LogBase.h
Normal file
75
rpcs3/Emu/SysCalls/LogBase.h
Normal file
@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
class LogBase
|
||||
{
|
||||
bool m_logging;
|
||||
|
||||
public:
|
||||
LogBase()
|
||||
: m_logging(false)
|
||||
{
|
||||
}
|
||||
|
||||
void SetLogging(bool value)
|
||||
{
|
||||
m_logging = value;
|
||||
}
|
||||
|
||||
virtual const std::string& GetName() const = 0;
|
||||
|
||||
template<typename... Targs> void Notice(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_NOTICE(HLE, GetName() + fmt::Format("[%d]: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Notice(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_NOTICE(HLE, GetName() + ": " + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> __forceinline void Log(const char* fmt, Targs... args)
|
||||
{
|
||||
if (m_logging)
|
||||
{
|
||||
Notice(fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Targs> __forceinline void Log(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
if (m_logging)
|
||||
{
|
||||
Notice(id, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Targs> void Warning(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_WARNING(HLE, GetName() + fmt::Format("[%d] warning: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Warning(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_WARNING(HLE, GetName() + " warning: " + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Error(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + fmt::Format("[%d] error: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Error(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + " error: " + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Todo(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + fmt::Format("[%d] TODO: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Todo(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + " TODO: " + fmt::Format(fmt, args...));
|
||||
}
|
||||
};
|
@ -148,7 +148,7 @@ u16 Module::GetID() const
|
||||
return m_id;
|
||||
}
|
||||
|
||||
std::string Module::GetName() const
|
||||
const std::string& Module::GetName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Emu/SysCalls/SC_FUNC.h"
|
||||
#include "LogBase.h"
|
||||
|
||||
//TODO
|
||||
struct ModuleFunc
|
||||
@ -41,7 +42,7 @@ struct SFunc
|
||||
}
|
||||
};
|
||||
|
||||
class Module
|
||||
class Module : public LogBase
|
||||
{
|
||||
std::string m_name;
|
||||
u16 m_id;
|
||||
@ -73,71 +74,10 @@ public:
|
||||
bool IsLoaded() const;
|
||||
|
||||
u16 GetID() const;
|
||||
std::string GetName() const;
|
||||
virtual const std::string& GetName() const override;
|
||||
void SetName(const std::string& name);
|
||||
|
||||
public:
|
||||
bool IsLogging()
|
||||
{
|
||||
return Ini.HLELogging.GetValue();
|
||||
}
|
||||
|
||||
template<typename... Targs> void Notice(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_NOTICE(HLE, GetName() + fmt::Format("[%d]: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Notice(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_NOTICE(HLE, GetName() + ": " + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> __forceinline void Log(const char* fmt, Targs... args)
|
||||
{
|
||||
if (IsLogging())
|
||||
{
|
||||
Notice(fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Targs> __forceinline void Log(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
if (IsLogging())
|
||||
{
|
||||
Notice(id, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Targs> void Warning(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_WARNING(HLE, GetName() + fmt::Format("[%d] warning: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Warning(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_WARNING(HLE, GetName() + " warning: " + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Error(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + fmt::Format("[%d] error: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Error(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + " error: " + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Todo(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + fmt::Format("[%d] TODO: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Todo(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + " TODO: " + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
bool CheckID(u32 id) const;
|
||||
template<typename T> bool CheckId(u32 id, T*& data)
|
||||
{
|
||||
|
@ -1206,7 +1206,7 @@ void libmixer_init()
|
||||
0xf000000048000000 // b
|
||||
);
|
||||
|
||||
REG_SUB_EMPTY(libmixer, "surmxUti", cellSurMixerUtilGetLevelFromDB);
|
||||
REG_SUB_EMPTY(libmixer, "surmxUti", cellSurMixerUtilGetLevelFromDBIndex);
|
||||
REG_SUB_EMPTY(libmixer, "surmxUti", cellSurMixerUtilNoteToRatio);
|
||||
REG_SUB(libmixer, "surmxUti", cellSurMixerUtilGetLevelFromDB, 0);
|
||||
REG_SUB(libmixer, "surmxUti", cellSurMixerUtilGetLevelFromDBIndex, 0);
|
||||
REG_SUB(libmixer, "surmxUti", cellSurMixerUtilNoteToRatio, 0);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "Emu/Event.h"
|
||||
|
||||
#include "rpcs3/Ini.h"
|
||||
#include "LogBase.h"
|
||||
|
||||
//#define SYSCALLS_DEBUG
|
||||
|
||||
@ -49,7 +50,7 @@ namespace detail{
|
||||
template<> bool CheckId<ID>(u32 id, ID*& _id,const std::string &name);
|
||||
}
|
||||
|
||||
class SysCallBase //Module
|
||||
class SysCallBase : public LogBase
|
||||
{
|
||||
private:
|
||||
std::string m_module_name;
|
||||
@ -62,67 +63,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& GetName() const { return m_module_name; }
|
||||
|
||||
bool IsLogging()
|
||||
virtual const std::string& GetName() const override
|
||||
{
|
||||
return Ini.HLELogging.GetValue();
|
||||
}
|
||||
|
||||
template<typename... Targs> void Notice(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_NOTICE(HLE, GetName() + fmt::Format("[%d]: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Notice(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_NOTICE(HLE, GetName() + ": " + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> __forceinline void Log(const char* fmt, Targs... args)
|
||||
{
|
||||
if (IsLogging())
|
||||
{
|
||||
Notice(fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Targs> __forceinline void Log(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
if (IsLogging())
|
||||
{
|
||||
Notice(id, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Targs> void Warning(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_WARNING(HLE, GetName() + fmt::Format("[%d] warning: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Warning(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_WARNING(HLE, GetName() + " warning: " + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Error(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + fmt::Format("[%d] error: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Error(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + " error: " + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Todo(const u32 id, const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + fmt::Format("[%d] TODO: ", id) + fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Targs> void Todo(const char* fmt, Targs... args)
|
||||
{
|
||||
LOG_ERROR(HLE, GetName() + " TODO: " + fmt::Format(fmt, args...));
|
||||
return m_module_name;
|
||||
}
|
||||
|
||||
bool CheckId(u32 id) const
|
||||
@ -190,7 +133,3 @@ public:
|
||||
#define REG_SUB(module, group, name, ...) \
|
||||
static const u64 name ## _table[] = {__VA_ARGS__ , 0}; \
|
||||
module->AddFuncSub(group, name ## _table, #name, name)
|
||||
|
||||
#define REG_SUB_EMPTY(module, group, name,...) \
|
||||
static const u64 name ## _table[] = {0}; \
|
||||
module->AddFuncSub(group, name ## _table, #name, name)
|
||||
|
@ -315,6 +315,7 @@
|
||||
<ClInclude Include="Emu\Memory\MemoryBlock.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Callback.h" />
|
||||
<ClInclude Include="Emu\SysCalls\ErrorCodes.h" />
|
||||
<ClInclude Include="Emu\SysCalls\LogBase.h" />
|
||||
<ClInclude Include="Emu\SysCalls\lv2\lv2Fs.h" />
|
||||
<ClInclude Include="Emu\SysCalls\lv2\sys_cond.h" />
|
||||
<ClInclude Include="Emu\SysCalls\lv2\sys_event.h" />
|
||||
|
@ -1093,5 +1093,8 @@
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellSync.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\SysCalls\LogBase.h">
|
||||
<Filter>Emu\SysCalls</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user