]> git.sesse.net Git - vlc/blobdiff - src/interface/intf_msg.c
. should compile & run on Solaris with ./configure --disable-dsp
[vlc] / src / interface / intf_msg.c
index 333433fb0d5d03f31e1cd3a6839f7ca315b0e230..dcb5b92ea29a917bfba461f6f8e36e8e6fc8a726 100644 (file)
@@ -102,7 +102,6 @@ typedef struct intf_msg_s
      * dummy integer is used to fill it. */
     int                     i_dummy;                        /* unused filler */
 #endif
-//    int                     i_warning_level;
 } intf_msg_t;
 
 /*****************************************************************************
@@ -384,17 +383,18 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
     /*
      * 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 );
     }
 
@@ -415,6 +415,9 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
      */
     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 */
@@ -445,11 +448,11 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
     /*
      * 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 )
     {
@@ -457,6 +460,7 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
                 strerror(errno) );
         fprintf(stderr, INTF_MSG_DBG_FORMAT, psz_file, psz_function, i_line );
         vfprintf(stderr, psz_format, ap );
+        fprintf(stderr, "\n" );
         exit( errno );
     }
 
@@ -464,9 +468,7 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function,
     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 */
@@ -539,7 +541,10 @@ static void PrintMsg( intf_msg_item_t *p_msg )
         break;
 
     case INTF_MSG_WARN:                                   /* Warning message */
-        asprintf( &psz_msg, "%s", p_msg->psz_msg );
+        mstrtime( psz_date, p_msg->date );
+        asprintf( &psz_msg, "(%s) %s",
+                  psz_date, p_msg->psz_msg );
+
         break;
         
     case INTF_MSG_INTF:                                /* interface messages */
@@ -568,14 +573,14 @@ static void PrintMsg( intf_msg_item_t *p_msg )
     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 );
@@ -587,6 +592,7 @@ static void PrintMsg( intf_msg_item_t *p_msg )
     if( p_main->p_msg->p_log_file != NULL )
     {
         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
 
@@ -605,11 +611,11 @@ static void PrintMsg( intf_msg_item_t *p_msg )
     {
     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 */
     case INTF_MSG_WARN:
-        fprintf( stderr, p_msg->psz_msg );                /* warning message */
+        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 );
@@ -618,3 +624,4 @@ static void PrintMsg( intf_msg_item_t *p_msg )
 }
 
 #endif
+