static void mux_printf(unsigned int mux_id, const char *format, ...) { va_list ap; if (opt_multiplex) { x_fprintf(x_stdout, "%d ", mux_id); } va_start(ap, format); x_vfprintf(x_stdout, format, ap); va_end(ap); }
/* ************************************************************************** ** * Write an debug message on the debugfile. * This is called by dbghdr() and format_debug_text(). * ************************************************************************** ** */ int Debug1( const char *format_str, ... ) { va_list ap; int old_errno = errno; debug_count++; if( stdout_logging ) { va_start( ap, format_str ); if(dbf) (void)x_vfprintf( dbf, format_str, ap ); va_end( ap ); errno = old_errno; return( 0 ); } #ifdef WITH_SYSLOG if( !lp_syslog_only() ) #endif { if( !dbf ) { mode_t oldumask = umask( 022 ); dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644 ); (void)umask( oldumask ); if( dbf ) { x_setbuf( dbf, NULL ); } else { errno = old_errno; return(0); } } } #ifdef WITH_SYSLOG if( syslog_level < lp_syslog() ) { /* map debug levels to syslog() priorities * note that not all DEBUG(0, ...) calls are * necessarily errors */ static int priority_map[] = { LOG_ERR, /* 0 */ LOG_WARNING, /* 1 */ LOG_NOTICE, /* 2 */ LOG_INFO, /* 3 */ }; int priority; pstring msgbuf; if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) ) || syslog_level < 0) priority = LOG_DEBUG; else priority = priority_map[syslog_level]; va_start( ap, format_str ); vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap ); va_end( ap ); msgbuf[255] = '\0'; syslog( priority, "%s", msgbuf ); } #endif check_log_size(); #ifdef WITH_SYSLOG if( !lp_syslog_only() ) #endif { va_start( ap, format_str ); if(dbf) (void)x_vfprintf( dbf, format_str, ap ); va_end( ap ); if(dbf) (void)x_fflush( dbf ); } errno = old_errno; return( 0 ); } /* Debug1 */