+ char *psz_file = config_GetPsz( p_intf, "logfile" );
+ if( !psz_file )
+ {
+#ifdef __APPLE__
+ if( asprintf( &psz_file, "%s/"LOG_DIR"/%s", config_GetHomeDir(),
+ (p_sys->msg.i_mode == MODE_HTML) ? LOG_FILE_HTML
+ : LOG_FILE_TEXT ) == -1 )
+ psz_file = NULL;
+#else
+ switch( p_sys->msg.i_mode )
+ {
+ case MODE_HTML:
+ psz_file = strdup( LOG_FILE_HTML );
+ break;
+ case MODE_TEXT:
+ default:
+ psz_file = strdup( LOG_FILE_TEXT );
+ break;
+ }
+#endif
+ msg_Warn( p_intf, "no log filename provided, using `%s'",
+ psz_file );
+ }
+
+ /* Open the log file and remove any buffering for the stream */
+ msg_Dbg( p_intf, "opening logfile `%s'", psz_file );
+ p_sys->msg.p_file = utf8_fopen( psz_file, "at" );
+ if( p_sys->msg.p_file == NULL )
+ {
+ msg_Err( p_intf, "error opening logfile `%s'", psz_file );
+ free( p_sys );
+ free( psz_file );
+ return -1;
+ }
+ setvbuf( p_sys->msg.p_file, NULL, _IONBF, 0 );
+
+ free( psz_file );
+
+ switch( p_sys->msg.i_mode )