mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +00:00
CDROM: Log command parameters
This commit is contained in:
parent
b9bd875c13
commit
edae13d9e4
|
@ -445,6 +445,20 @@ void Log::SetFileOutputParams(bool enabled, const char* filename, bool timestamp
|
|||
s_file_output_timestamp = timestamps;
|
||||
}
|
||||
|
||||
LOGLEVEL Log::GetLogLevel()
|
||||
{
|
||||
return s_log_level;
|
||||
}
|
||||
|
||||
bool Log::IsLogVisible(LOGLEVEL level, const char* channelName)
|
||||
{
|
||||
if (level > s_log_level)
|
||||
return false;
|
||||
|
||||
std::unique_lock lock(s_callback_mutex);
|
||||
return FilterTest(level, channelName, lock);
|
||||
}
|
||||
|
||||
void Log::SetLogLevel(LOGLEVEL level)
|
||||
{
|
||||
std::unique_lock lock(s_callback_mutex);
|
||||
|
@ -452,7 +466,7 @@ void Log::SetLogLevel(LOGLEVEL level)
|
|||
s_log_level = level;
|
||||
}
|
||||
|
||||
void Log::SetLogfilter(std::string_view filter)
|
||||
void Log::SetLogFilter(std::string_view filter)
|
||||
{
|
||||
std::unique_lock lock(s_callback_mutex);
|
||||
if (s_log_filter != filter)
|
||||
|
|
|
@ -52,11 +52,17 @@ void SetDebugOutputParams(bool enabled);
|
|||
// adds a file output
|
||||
void SetFileOutputParams(bool enabled, const char* filename, bool timestamps = true);
|
||||
|
||||
// Returns the current global filtering level.
|
||||
LOGLEVEL GetLogLevel();
|
||||
|
||||
// Returns true if log messages for the specified log level/filter would not be filtered (and visible).
|
||||
bool IsLogVisible(LOGLEVEL level, const char* channelName);
|
||||
|
||||
// Sets global filtering level, messages below this level won't be sent to any of the logging sinks.
|
||||
void SetLogLevel(LOGLEVEL level);
|
||||
|
||||
// Sets global filter, any messages from these channels won't be sent to any of the logging sinks.
|
||||
void SetLogfilter(std::string_view filter);
|
||||
void SetLogFilter(std::string_view filter);
|
||||
|
||||
// writes a message to the log
|
||||
void Write(const char* channelName, const char* functionName, LOGLEVEL level, std::string_view message);
|
||||
|
@ -98,6 +104,14 @@ ALWAYS_INLINE static void WriteFmt(const char* channelName, const char* function
|
|||
#define Log_ProfilePrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_PROFILE, __VA_ARGS__)
|
||||
#define Log_ProfileFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_PROFILE, __VA_ARGS__)
|
||||
|
||||
#define Log_ErrorVisible() Log::IsLogVisible(LOGLEVEL_ERROR, ___LogChannel___)
|
||||
#define Log_WarningVisible() Log::IsLogVisible(LOGLEVEL_WARNING, ___LogChannel___)
|
||||
#define Log_PerfVisible() Log::IsLogVisible(LOGLEVEL_PERF, ___LogChannel___)
|
||||
#define Log_InfoVisible() Log::IsLogVisible(LOGLEVEL_INFO, ___LogChannel___)
|
||||
#define Log_VerboseVisible() Log::IsLogVisible(LOGLEVEL_VERBOSE, ___LogChannel___)
|
||||
#define Log_DevVisible() Log::IsLogVisible(LOGLEVEL_DEV, ___LogChannel___)
|
||||
#define Log_ProfileVisible() Log::IsLogVisible(LOGLEVEL_PROFILE, ___LogChannel___)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define Log_DebugPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_DEBUG, msg)
|
||||
#define Log_DebugPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_DEBUG, __VA_ARGS__)
|
||||
|
@ -105,6 +119,9 @@ ALWAYS_INLINE static void WriteFmt(const char* channelName, const char* function
|
|||
#define Log_TracePrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_TRACE, msg)
|
||||
#define Log_TracePrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_TRACE, __VA_ARGS__)
|
||||
#define Log_TraceFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_TRACE, __VA_ARGS__)
|
||||
|
||||
#define Log_DebugVisible() Log::IsLogVisible(LOGLEVEL_DEBUG, ___LogChannel___)
|
||||
#define Log_TraceVisible() Log::IsLogVisible(LOGLEVEL_TRACE, ___LogChannel___)
|
||||
#else
|
||||
#define Log_DebugPrint(msg) \
|
||||
do \
|
||||
|
@ -130,4 +147,7 @@ ALWAYS_INLINE static void WriteFmt(const char* channelName, const char* function
|
|||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
|
||||
#define Log_DebugVisible() false
|
||||
#define Log_TraceVisible() false
|
||||
#endif
|
||||
|
|
|
@ -172,6 +172,18 @@ void SmallStringBase::append(const char* str, u32 length)
|
|||
m_buffer[m_length] = 0;
|
||||
}
|
||||
|
||||
void SmallStringBase::append_hex(const void* data, size_t len)
|
||||
{
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
make_room_for(static_cast<u32>(len) * 4);
|
||||
const u8* bytes = static_cast<const u8*>(data);
|
||||
append_fmt("{:02X}", bytes[0]);
|
||||
for (size_t i = 1; i < len; i++)
|
||||
append_fmt(", {:02X}", bytes[i]);
|
||||
}
|
||||
|
||||
void SmallStringBase::prepend(const char* str, u32 length)
|
||||
{
|
||||
if (length == 0)
|
||||
|
|
|
@ -64,6 +64,9 @@ public:
|
|||
template<typename... T>
|
||||
void append_fmt(fmt::format_string<T...> fmt, T&&... args);
|
||||
|
||||
// append hex string
|
||||
void append_hex(const void* data, size_t len);
|
||||
|
||||
// append a single character to this string
|
||||
void prepend(char c);
|
||||
|
||||
|
|
|
@ -1397,12 +1397,19 @@ void CDROM::EndCommand()
|
|||
void CDROM::ExecuteCommand(void*, TickCount ticks, TickCount ticks_late)
|
||||
{
|
||||
const CommandInfo& ci = s_command_info[static_cast<u8>(s_command)];
|
||||
Log_DevPrintf("CDROM executing command 0x%02X (%s), stat = 0x%02X", static_cast<u8>(s_command), ci.name,
|
||||
s_secondary_status.bits);
|
||||
if (s_param_fifo.GetSize() < ci.expected_parameters)
|
||||
if (Log_DevVisible()) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrintf("Too few parameters for command 0x%02X (%s), expecting %u got %u", static_cast<u8>(s_command),
|
||||
ci.name, ci.expected_parameters, s_param_fifo.GetSize());
|
||||
SmallString params;
|
||||
for (u32 i = 0; i < s_param_fifo.GetSize(); i++)
|
||||
params.append_fmt("{}0x{:02X}", (i == 0) ? "" : ", ", s_param_fifo.Peek(i));
|
||||
Log_DevFmt("CDROM executing command 0x{:02X} ({}), stat = 0x{:02X}, params = [{}]", static_cast<u8>(s_command),
|
||||
ci.name, s_secondary_status.bits, params);
|
||||
}
|
||||
|
||||
if (s_param_fifo.GetSize() < ci.expected_parameters) [[unlikely]]
|
||||
{
|
||||
Log_WarningFmt("Too few parameters for command 0x{:02X} ({}), expecting {} got {}", static_cast<u8>(s_command),
|
||||
ci.name, ci.expected_parameters, s_param_fifo.GetSize());
|
||||
SendErrorResponse(STAT_ERROR, ERROR_REASON_INCORRECT_NUMBER_OF_PARAMETERS);
|
||||
EndCommand();
|
||||
return;
|
||||
|
|
|
@ -704,7 +704,7 @@ void Settings::FixIncompatibleSettings(bool display_osd_messages)
|
|||
void Settings::UpdateLogSettings()
|
||||
{
|
||||
Log::SetLogLevel(log_level);
|
||||
Log::SetLogfilter(log_filter);
|
||||
Log::SetLogFilter(log_filter);
|
||||
Log::SetConsoleOutputParams(log_to_console, log_timestamps);
|
||||
Log::SetDebugOutputParams(log_to_debug);
|
||||
|
||||
|
|
Loading…
Reference in a new issue