summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-06-25 11:43:03 -0600
committerBrian Paul <[email protected]>2012-06-25 16:10:01 -0600
commit9ccf5bffe360def72c8f96340a524fdd672354ec (patch)
tree6b16a310a5622bd186e15eb4de62e4b6f4ef1544 /src
parent0f530d2dff20ccccb016341d0b65123e5868bbb4 (diff)
mesa: new MESA_LOG_FILE env var to log errors, warnings, etc., to a file
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/errors.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index 69dbb65cf40..ef78a0bca46 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -801,12 +801,21 @@ 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
* by now so MESA_DEBUG_FLAGS will be initialized.
*/
if (debug == -1) {
+ /* If MESA_LOG_FILE env var is set, log Mesa errors, warnings,
+ * etc to the named file. Otherwise, output to stderr.
+ */
+ const char *logFile = _mesa_getenv("MESA_LOG_FILE");
+ if (logFile)
+ fout = fopen(logFile, "w");
+ if (!fout)
+ fout = stderr;
#ifdef DEBUG
/* in debug builds, print messages unless MESA_DEBUG="silent" */
if (MESA_DEBUG_FLAGS & DEBUG_SILENT)
@@ -821,9 +830,10 @@ output_if_debug(const char *prefixString, const char *outputString,
/* Now only print the string if we're required to do so. */
if (debug) {
- fprintf(stderr, "%s: %s", prefixString, outputString);
+ fprintf(fout, "%s: %s", prefixString, outputString);
if (newline)
- fprintf(stderr, "\n");
+ fprintf(fout, "\n");
+ fflush(fout);
#if defined(_WIN32) && !defined(_WIN32_WCE)
/* stderr from windows applications without console is not usually