mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-13 13:30:44 +00:00
Expose full logging to UI layer, pipe Qt messages etc into main logs
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
||||
@@ -30,9 +30,27 @@
|
||||
#include "Code/CaptureContext.h"
|
||||
#include "Windows/MainWindow.h"
|
||||
|
||||
void sharedLogOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
LogMessageType logtype = eLogType_Comment;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case QtDebugMsg: logtype = eLogType_Debug; break;
|
||||
case QtInfoMsg: logtype = eLogType_Comment; break;
|
||||
case QtWarningMsg: logtype = eLogType_Warning; break;
|
||||
case QtCriticalMsg: logtype = eLogType_Error; break;
|
||||
case QtFatalMsg: logtype = eLogType_Fatal; break;
|
||||
}
|
||||
|
||||
RENDERDOC_LogMessage(logtype, "QTRD", context.file, context.line, msg.toUtf8().data());
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
RENDERDOC_LogText("QRenderDoc initialising.");
|
||||
qInstallMessageHandler(sharedLogOutput);
|
||||
|
||||
qInfo() << "QRenderDoc initialising.";
|
||||
|
||||
QString filename = "";
|
||||
bool temp = false;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include "ThumbnailStrip.h"
|
||||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
#include "Widgets/ResourcePreview.h"
|
||||
#include "ui_ThumbnailStrip.h"
|
||||
|
||||
@@ -643,6 +643,9 @@ extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_InjectIntoProcess(
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_TriggerExceptionHandler(void *exceptionPtrs,
|
||||
bool32 crashed);
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_LogText(const char *text);
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_LogMessage(LogMessageType type,
|
||||
const char *project, const char *file,
|
||||
unsigned int line, const char *text);
|
||||
extern "C" RENDERDOC_API bool32 RENDERDOC_CC RENDERDOC_GetThumbnail(const char *filename, byte *buf,
|
||||
uint32_t &len);
|
||||
extern "C" RENDERDOC_API const char *RENDERDOC_CC RENDERDOC_GetVersionString();
|
||||
|
||||
@@ -554,3 +554,15 @@ enum EnvironmentSeparator
|
||||
eEnvSep_Colon,
|
||||
eEnvSep_None,
|
||||
};
|
||||
|
||||
// matches enum in common.h
|
||||
enum LogMessageType
|
||||
{
|
||||
eLogType_First = -1,
|
||||
eLogType_Debug,
|
||||
eLogType_Comment,
|
||||
eLogType_Warning,
|
||||
eLogType_Error,
|
||||
eLogType_Fatal,
|
||||
eLogType_NumTypes,
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ float SRGB8_lookuptable[256] = {
|
||||
|
||||
void rdcassert(const char *msg, const char *file, unsigned int line, const char *func)
|
||||
{
|
||||
rdclog_int(RDCLog_Error, file, line, "Assertion failed: %s", msg);
|
||||
rdclog_int(RDCLog_Error, RDCLOG_PROJECT, file, line, "Assertion failed: %s", msg);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -319,7 +319,8 @@ void rdclogprint_int(LogType type, const char *fullMsg, const char *msg)
|
||||
const size_t rdclog_outBufSize = 4 * 1024;
|
||||
static char rdclog_outputBuffer[rdclog_outBufSize + 1];
|
||||
|
||||
void rdclog_int(LogType type, const char *file, unsigned int line, const char *fmt, ...)
|
||||
void rdclog_int(LogType type, const char *project, const char *file, unsigned int line,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
if(type <= RDCLog_First || type >= RDCLog_NumTypes)
|
||||
{
|
||||
@@ -330,8 +331,6 @@ void rdclog_int(LogType type, const char *file, unsigned int line, const char *f
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
const char *name = "RENDERDOC: ";
|
||||
|
||||
char timestamp[64] = {0};
|
||||
#if defined(INCLUDE_TIMESTAMP_IN_LOG)
|
||||
StringFormat::sntimef(timestamp, 63, "[%H:%M:%S] ");
|
||||
@@ -357,7 +356,7 @@ void rdclog_int(LogType type, const char *file, unsigned int line, const char *f
|
||||
char *output = rdclog_outputBuffer;
|
||||
size_t available = rdclog_outBufSize;
|
||||
|
||||
int numWritten = StringFormat::snprintf(output, available, "%s %s%s%s - ", name, timestamp,
|
||||
int numWritten = StringFormat::snprintf(output, available, "% 4s: %s%s%s - ", project, timestamp,
|
||||
location, typestr[type]);
|
||||
|
||||
if(numWritten < 0)
|
||||
|
||||
@@ -253,10 +253,15 @@ void rdclog_flush();
|
||||
// fatal error messages from within the more complex log function).
|
||||
void rdclogprint_int(LogType type, const char *fullMsg, const char *msg);
|
||||
|
||||
// printf() style main logger function
|
||||
void rdclog_int(LogType type, const char *file, unsigned int line, const char *fmt, ...);
|
||||
#if !defined(RDCLOG_PROJECT)
|
||||
#define RDCLOG_PROJECT "RDOC"
|
||||
#endif
|
||||
|
||||
#define rdclog(type, ...) rdclog_int(type, __FILE__, __LINE__, __VA_ARGS__)
|
||||
// printf() style main logger function
|
||||
void rdclog_int(LogType type, const char *project, const char *file, unsigned int line,
|
||||
const char *fmt, ...);
|
||||
|
||||
#define rdclog(type, ...) rdclog_int(type, RDCLOG_PROJECT, __FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
const char *rdclog_getfilename();
|
||||
void rdclog_filename(const char *filename);
|
||||
|
||||
@@ -70,8 +70,8 @@ public:
|
||||
|
||||
~ScopedTimer()
|
||||
{
|
||||
rdclog_int(RDCLog_Comment, m_File, m_Line, "Timer %s - %.3lf ms", m_Message.c_str(),
|
||||
m_Timer.GetMilliseconds());
|
||||
rdclog_int(RDCLog_Comment, RDCLOG_PROJECT, m_File, m_Line, "Timer %s - %.3lf ms",
|
||||
m_Message.c_str(), m_Timer.GetMilliseconds());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -281,7 +281,16 @@ extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_FreeEnvironmentModification
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_LogText(const char *text)
|
||||
{
|
||||
RDCLOG("%s", text);
|
||||
rdclog_int(RDCLog_Comment, "EXT", "external", 0, "%s", text);
|
||||
}
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_LogMessage(LogMessageType type,
|
||||
const char *project, const char *file,
|
||||
unsigned int line, const char *text)
|
||||
{
|
||||
RDCCOMPILE_ASSERT(eLogType_First == RDCLog_First && eLogType_NumTypes == eLogType_NumTypes,
|
||||
"Log type enum is out of sync");
|
||||
rdclog_int((LogType)type, project, file, line, "%s", text);
|
||||
}
|
||||
|
||||
extern "C" RENDERDOC_API const char *RENDERDOC_CC RENDERDOC_GetLogFile()
|
||||
|
||||
Reference in New Issue
Block a user