#define INTF_MSG_ERR 1 /* error message */
#define INTF_MSG_INTF 2 /* interface message */
#define INTF_MSG_DBG 3 /* debug message */
+#define INTF_MSG_WARN 4 /* warning message*/
+
/*****************************************************************************
* intf_msg_t
#ifdef DEBUG_LOG
/* Log file */
- int i_log_file; /* log file */
+ FILE * p_log_file; /* log file */
#endif
#if !defined(INTF_MSG_QUEUE) && !defined(DEBUG_LOG)
p_msg->i_count = 0; /* queue is empty */
#endif
+
#ifdef DEBUG_LOG
/* Log file initialization - on failure, file pointer will be null,
* and no log will be issued, but this is not considered as an
* error */
- p_msg->i_log_file = open( DEBUG_LOG, O_CREAT | O_TRUNC |
-#ifndef SYS_BSD
- O_SYNC |
-#else
- O_ASYNC |
-#endif /* SYS_BSD */
- O_WRONLY, 0666 );
-
+ p_msg->p_log_file = fopen( DEBUG_LOG, "w" );
#endif
}
return( p_msg );
#ifdef DEBUG_LOG
/* Close log file if any */
- if( p_main->p_msg->i_log_file >= 0 )
+ if( p_main->p_msg->p_log_file != NULL )
{
- close( p_main->p_msg->i_log_file );
+ fclose( p_main->p_msg->p_log_file );
}
#endif
* This function is the same as intf_Msg, except that it prints its messages
* on stderr.
*****************************************************************************/
-void intf_ErrMsg( char *psz_format, ...)
+void intf_ErrMsg( char *psz_format, ... )
{
va_list ap;
va_end( ap );
}
+/*****************************************************************************
+ * intf_WarnMsg : print a warning message
+ *****************************************************************************
+ * This function is the same as intf_Msg, except that it concerns warning
+ * messages for testing purpose.
+ *****************************************************************************/
+void intf_WarnMsg( int i_level, char *psz_format, ... )
+{
+ va_list ap;
+
+ if( i_level >= p_main->p_intf->i_warning_level )
+ {
+ va_start( ap, psz_format );
+ QueueMsg( p_main->p_msg, INTF_MSG_WARN, psz_format, ap );
+ va_end( ap );
+ }
+}
+
+
/*****************************************************************************
* intf_IntfMsg : print an interface message (ok ?)
*****************************************************************************
#endif
/*****************************************************************************
- * intf_ErrMsgImm: print a message (ok ?)
+ * intf_MsgImm: print a message (ok ?)
*****************************************************************************
* This function prints a message immediately. If the queue is used, all
* waiting messages are also printed.
intf_FlushMsg();
}
+/*****************************************************************************
+ * intf_WarnMsgImm : print a warning message
+ *****************************************************************************
+ * This function is the same as intf_MsgImm, except that it concerns warning
+ * messages for testing purpose.
+ *****************************************************************************/
+void intf_WarnMsgImm( int i_level, char *psz_format, ... )
+{
+ va_list ap;
+
+ if( i_level >= p_main->p_intf->i_warning_level )
+ {
+ va_start( ap, psz_format );
+ QueueMsg( p_main->p_msg, INTF_MSG_WARN, psz_format, ap );
+ va_end( ap );
+ }
+ intf_FlushMsg();
+}
+
+
+
/*****************************************************************************
* _intf_DbgMsgImm: print a debugging message immediately (ok ?)
*****************************************************************************
/*
* Convert message to string
*/
-#ifdef SYS_BEOS
+#ifdef HAVE_VASPRINTF
+ vasprintf( &psz_str, psz_format, ap );
+#else
psz_str = (char*) malloc( strlen(psz_format) + INTF_MAX_MSG_SIZE );
vsprintf( psz_str, psz_format, ap );
-#else
- vasprintf( &psz_str, psz_format, ap );
#endif
if( psz_str == NULL )
{
fprintf(stderr, "warning: can't store following message (%s): ",
strerror(errno) );
vfprintf(stderr, psz_format, ap );
+ fprintf(stderr, "\n" );
exit( errno );
}
*/
p_msg_item->i_type = i_type;
p_msg_item->psz_msg = psz_str;
+#ifdef DEBUG
+ p_msg_item->date = mdate();
+#endif
#ifdef INTF_MSG_QUEUE /*......................................... queue mode */
vlc_mutex_unlock( &p_msg->lock ); /* give lock back */
/*
* Convert message to string
*/
-#ifdef SYS_BEOS
+#ifdef HAVE_VASPRINTF
+ vasprintf( &psz_str, psz_format, ap );
+#else
psz_str = (char*) malloc( INTF_MAX_MSG_SIZE );
vsprintf( psz_str, psz_format, ap );
-#else
- vasprintf( &psz_str, psz_format, ap );
#endif
if( psz_str == NULL )
{
strerror(errno) );
fprintf(stderr, INTF_MSG_DBG_FORMAT, psz_file, psz_function, i_line );
vfprintf(stderr, psz_format, ap );
+ fprintf(stderr, "\n" );
exit( errno );
}
vlc_mutex_lock( &p_msg->lock ); /* get lock */
if( p_msg->i_count == INTF_MSG_QSIZE ) /* flush queue if needed */
{
-#ifdef DEBUG /* in debug mode, queue overflow causes a warning */
fprintf(stderr, "warning: message queue overflow\n" );
-#endif
FlushLockedMsg( p_msg );
}
p_msg_item = p_msg->msg + p_msg->i_count++; /* select message */
asprintf( &psz_msg, "%s", p_msg->psz_msg );
break;
+ case INTF_MSG_WARN: /* Warning message */
+ mstrtime( psz_date, p_msg->date );
+ asprintf( &psz_msg, "(%s) %s",
+ psz_date, p_msg->psz_msg );
+
+ break;
+
case INTF_MSG_INTF: /* interface messages */
asprintf( &psz_msg, "%s", p_msg->psz_msg );
break;
break;
}
- /* Check if formatting function suceeded */
+ /* Check if formatting function succeeded */
if( psz_msg == NULL )
{
fprintf( stderr, "error: can not format message (%s): %s\n",
switch( p_msg->i_type )
{
case INTF_MSG_STD: /* standard messages */
- fprintf( stdout, psz_msg );
+ fprintf( stdout, "%s\n", psz_msg );
break;
case INTF_MSG_ERR: /* error messages */
+ case INTF_MSG_WARN:
#ifndef DEBUG_LOG_ONLY
case INTF_MSG_DBG: /* debugging messages */
#endif
- fprintf( stderr, psz_msg );
+ fprintf( stderr, "%s\n", psz_msg );
break;
case INTF_MSG_INTF: /* interface messages */
intf_ConsolePrint( p_main->p_intf->p_console, psz_msg );
#ifdef DEBUG_LOG
/* Append all messages to log file */
- if( p_main->p_msg->i_log_file >= 0 )
+ if( p_main->p_msg->p_log_file != NULL )
{
- write( p_main->p_msg->i_log_file, psz_msg, strlen( psz_msg ) );
+ fwrite( psz_msg, strlen( psz_msg ), 1, p_main->p_msg->p_log_file );
+ fwrite( "\n", 1, 1, p_main->p_msg->p_log_file );
}
#endif
{
case INTF_MSG_STD: /* standard messages */
case INTF_MSG_DBG: /* debug messages */
- fprintf( stdout, p_msg->psz_msg );
+ fprintf( stdout, "%s\n", p_msg->psz_msg );
break;
case INTF_MSG_ERR: /* error messages */
- fprintf( stderr, p_msg->psz_msg );
+ case INTF_MSG_WARN:
+ fprintf( stderr, "%s\n", p_msg->psz_msg ); /* warning message */
break;
case INTF_MSG_INTF: /* interface messages */
intf_ConsolePrint( p_main->p_intf->p_console, p_msg->psz_msg );
}
#endif
+