[Mesa-dev] [PATCH] auxilary/os: allow appending to GALLIUM_LOG_FILE
Brian Paul
brianp at vmware.com
Wed Jun 15 15:59:40 UTC 2016
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.
---
src/gallium/auxiliary/os/os_misc.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/gallium/auxiliary/os/os_misc.c b/src/gallium/auxiliary/os/os_misc.c
index d6b83e9..6e9e0f7 100644
--- a/src/gallium/auxiliary/os/os_misc.c
+++ b/src/gallium/auxiliary/os/os_misc.c
@@ -71,8 +71,17 @@ os_log_message(const char *message)
if (!fout) {
/* 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);
+ }
if (!fout)
fout = stderr;
}
--
1.9.1
More information about the mesa-dev
mailing list