mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-21 16:20:39 +02:00
mesa: add _mesa_log(), _mesa_get_log_file() functions
_mesa_log() simply writes log information to stderr or MESA_LOG_FILE. _mesa_get_log_file() returns the file handle to use for logging. This will be used for shader dumping/logging instead of always printing to stderr. Reviewed-by: José Fonseca <jfonseca@vmware.com>
This commit is contained in:
parent
11bfee4c3a
commit
2926bbfb28
2 changed files with 43 additions and 7 deletions
|
|
@ -1232,12 +1232,14 @@ _mesa_free_errors_data(struct gl_context *ctx)
|
|||
/** \name Diagnostics */
|
||||
/*@{*/
|
||||
|
||||
static FILE *LogFile = NULL;
|
||||
|
||||
|
||||
static void
|
||||
output_if_debug(const char *prefixString, const char *outputString,
|
||||
GLboolean newline)
|
||||
{
|
||||
static int debug = -1;
|
||||
static FILE *fout = NULL;
|
||||
|
||||
/* Init the local 'debug' var once.
|
||||
* Note: the _mesa_init_debug() function should have been called
|
||||
|
|
@ -1249,9 +1251,9 @@ output_if_debug(const char *prefixString, const char *outputString,
|
|||
*/
|
||||
const char *logFile = getenv("MESA_LOG_FILE");
|
||||
if (logFile)
|
||||
fout = fopen(logFile, "w");
|
||||
if (!fout)
|
||||
fout = stderr;
|
||||
LogFile = fopen(logFile, "w");
|
||||
if (!LogFile)
|
||||
LogFile = stderr;
|
||||
#ifdef DEBUG
|
||||
/* in debug builds, print messages unless MESA_DEBUG="silent" */
|
||||
if (MESA_DEBUG_FLAGS & DEBUG_SILENT)
|
||||
|
|
@ -1266,10 +1268,13 @@ output_if_debug(const char *prefixString, const char *outputString,
|
|||
|
||||
/* Now only print the string if we're required to do so. */
|
||||
if (debug) {
|
||||
fprintf(fout, "%s: %s", prefixString, outputString);
|
||||
if (prefixString)
|
||||
fprintf(LogFile, "%s: %s", prefixString, outputString);
|
||||
else
|
||||
fprintf(LogFile, "%s", outputString);
|
||||
if (newline)
|
||||
fprintf(fout, "\n");
|
||||
fflush(fout);
|
||||
fprintf(LogFile, "\n");
|
||||
fflush(LogFile);
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* stderr from windows applications without console is not usually
|
||||
|
|
@ -1284,6 +1289,18 @@ output_if_debug(const char *prefixString, const char *outputString,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the file handle to use for debug/logging. Defaults to stderr
|
||||
* unless MESA_LOG_FILE is defined.
|
||||
*/
|
||||
FILE *
|
||||
_mesa_get_log_file(void)
|
||||
{
|
||||
assert(LogFile);
|
||||
return LogFile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* When a new type of error is recorded, print a message describing
|
||||
* previous errors which were accumulated.
|
||||
|
|
@ -1525,6 +1542,18 @@ _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... )
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_log(const char *fmtString, ...)
|
||||
{
|
||||
char s[MAX_DEBUG_MESSAGE_LENGTH];
|
||||
va_list args;
|
||||
va_start(args, fmtString);
|
||||
_mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
|
||||
va_end(args);
|
||||
output_if_debug("", s, GL_FALSE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Report debug information from the shader compiler via GL_ARB_debug_output.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#define ERRORS_H
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "compiler.h"
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
|
|
@ -68,6 +69,12 @@ _mesa_error_no_memory(const char *caller);
|
|||
extern void
|
||||
_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
|
||||
|
||||
extern void
|
||||
_mesa_log(const char *fmtString, ...) PRINTFLIKE(1, 2);
|
||||
|
||||
extern FILE *
|
||||
_mesa_get_log_file(void);
|
||||
|
||||
extern void
|
||||
_mesa_gl_debug(struct gl_context *ctx,
|
||||
GLuint *id,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue