Commit 4676ccbc authored by Christophe Massiot's avatar Christophe Massiot

Now using buffer I/O to write debug logs (huge performance increase).

parent c80fb561
...@@ -93,10 +93,9 @@ typedef struct intf_msg_s ...@@ -93,10 +93,9 @@ typedef struct intf_msg_s
#ifdef DEBUG_LOG #ifdef DEBUG_LOG
/* Log file */ /* Log file */
int i_log_file; /* log file */ FILE * p_log_file; /* log file */
#endif #endif
//#if 0
#if !defined(INTF_MSG_QUEUE) && !defined(DEBUG_LOG) #if !defined(INTF_MSG_QUEUE) && !defined(DEBUG_LOG)
/* If neither messages queue, neither log file is used, then the structure /* If neither messages queue, neither log file is used, then the structure
* is empty. However, empty structures are not allowed in C. Therefore, a * is empty. However, empty structures are not allowed in C. Therefore, a
...@@ -152,14 +151,7 @@ p_intf_msg_t intf_MsgCreate( void ) ...@@ -152,14 +151,7 @@ p_intf_msg_t intf_MsgCreate( void )
/* Log file initialization - on failure, file pointer will be null, /* Log file initialization - on failure, file pointer will be null,
* and no log will be issued, but this is not considered as an * and no log will be issued, but this is not considered as an
* error */ * error */
p_msg->i_log_file = open( DEBUG_LOG, O_CREAT | O_TRUNC | p_msg->p_log_file = fopen( DEBUG_LOG, "w" );
#ifndef SYS_BSD
O_SYNC |
#else
O_ASYNC |
#endif /* SYS_BSD */
O_WRONLY, 0666 );
#endif #endif
} }
return( p_msg ); return( p_msg );
...@@ -178,9 +170,9 @@ void intf_MsgDestroy( void ) ...@@ -178,9 +170,9 @@ void intf_MsgDestroy( void )
#ifdef DEBUG_LOG #ifdef DEBUG_LOG
/* Close log file if any */ /* 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 #endif
...@@ -592,9 +584,9 @@ static void PrintMsg( intf_msg_item_t *p_msg ) ...@@ -592,9 +584,9 @@ static void PrintMsg( intf_msg_item_t *p_msg )
#ifdef DEBUG_LOG #ifdef DEBUG_LOG
/* Append all messages to log file */ /* 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 );
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment