#include "ldap_pvt.h"
static FILE *log_file = NULL;
+static int debug_lastc = '\n';
int lutil_debug_file( FILE *file )
{
{
char buffer[4096];
va_list vl;
+ int len, off;
if ( !(level & debug ) ) return;
}
#endif
- sprintf(buffer, "%08x ", (unsigned) time(0L));
+ if (debug_lastc == '\n') {
+ sprintf(buffer, "%08x ", (unsigned) time(0L));
+ off = 9;
+ } else {
+ off = 0;
+ }
va_start( vl, fmt );
- vsnprintf( buffer+9, sizeof(buffer)-9, fmt, vl );
+ len = vsnprintf( buffer+off, sizeof(buffer)-off, fmt, vl );
+ if (len > sizeof(buffer)-off)
+ len = sizeof(buffer)-off;
+ debug_lastc = buffer[len+off-1];
buffer[sizeof(buffer)-1] = '\0';
if( log_file != NULL ) {
fputs( buffer, log_file );