util: allow GALLIUM_LOG_FILE=stdout

To log gallium info to stdout instead of a file.

Signed-off-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18213>
This commit is contained in:
Brian Paul 2022-07-15 22:02:08 -06:00 committed by Marge Bot
parent 69f7c91fe9
commit 2967cc25ea

View file

@ -86,15 +86,19 @@ os_log_message(const char *message)
/* one-time init */
const char *filename = os_get_option("GALLIUM_LOG_FILE");
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";
if (strcmp(filename, "stdout") == 0) {
fout = stdout;
} else {
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);
}
fout = fopen(filename, mode);
}
#endif
if (!fout)