summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2016-06-14 20:35:53 -0600
committerBrian Paul <brianp@vmware.com>2016-06-15 17:16:42 -0600
commitbb1292e2261fa591cf66de443a1b0d4eb7f65cb2 (patch)
treeefbde36bbd61ec6e56e066285b59362bb5b67166
parentc99a0a8bcece2870f3e93328ab520efc2c9f7983 (diff)
downloadexternal_mesa3d-bb1292e2261fa591cf66de443a1b0d4eb7f65cb2.zip
external_mesa3d-bb1292e2261fa591cf66de443a1b0d4eb7f65cb2.tar.gz
external_mesa3d-bb1292e2261fa591cf66de443a1b0d4eb7f65cb2.tar.bz2
auxilary/os: allow appending to GALLIUM_LOG_FILE
If the log file specified by the GALLIUM_LOG_FILE begins with '+', open the file in append mode. This is useful to log all gallium output for an entire piglit run, for example. v2: put GALLIUM_LOG_FILE support inside an #ifdef DEBUG block. Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
-rw-r--r--src/gallium/auxiliary/os/os_misc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/os/os_misc.c b/src/gallium/auxiliary/os/os_misc.c
index d6b83e9..82e4957 100644
--- a/src/gallium/auxiliary/os/os_misc.c
+++ b/src/gallium/auxiliary/os/os_misc.c
@@ -69,10 +69,21 @@ os_log_message(const char *message)
static FILE *fout = NULL;
if (!fout) {
+#ifdef DEBUG
/* one-time init */
const char *filename = os_get_option("GALLIUM_LOG_FILE");
- if (filename)
- fout = fopen(filename, "w");
+ if (filename) {
+ const char *mode = "w";
+ if (filename[0] == '+') {
+ /* If the filename is prefixed with '+' then open the file for
+ * appending instead of normal writing.
+ */
+ mode = "a";
+ filename++; /* skip the '+' */
+ }
+ fout = fopen(filename, mode);
+ }
+#endif
if (!fout)
fout = stderr;
}