From 861a933b7b518392920a5723e1a2df71ead4f7e9 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 21 May 2010 18:16:27 -0700 Subject: Use the ALSOFT_LOGFILE env var to specify the output for AL_PRINT --- Alc/ALc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'Alc/ALc.c') diff --git a/Alc/ALc.c b/Alc/ALc.c index ae568b2b..c76fe1ac 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -365,6 +365,9 @@ static ALint RTPrioLevel; // Resampler Quality resampler_t DefaultResampler; +// Output Log File +static FILE *LogFile; + /////////////////////////////////////////////////////// @@ -410,6 +413,16 @@ static void alc_init(void) tls_create(&LocalContext); + str = getenv("ALSOFT_LOGFILE"); + if(str && str[0]) + { + LogFile = fopen(str, "w"); + if(!LogFile) + fprintf(stderr, "AL lib: Failed to open log file '%s'\n", str); + } + if(!LogFile) + LogFile = stderr; + RTPrioLevel = GetConfigValueInt(NULL, "rt-prio", 0); DefaultResampler = GetConfigValueInt(NULL, "resampler", RESAMPLER_DEFAULT); @@ -512,6 +525,10 @@ static void alc_deinit(void) for(i = 0;BackendList[i].Deinit;i++) BackendList[i].Deinit(); + if(LogFile != stderr) + fclose(LogFile); + LogFile = NULL; + tls_delete(LocalContext); FreeALConfig(); @@ -601,7 +618,8 @@ void al_print(const char *fname, unsigned int line, const char *fmt, ...) } str[sizeof(str)-1] = 0; - fprintf(stderr, "%s", str); + fprintf(LogFile, "%s", str); + fflush(LogFile); } void SetRTPriority(void) -- cgit v1.2.3