@ -93,39 +93,49 @@ void status_send(const u8 *msg TAKES)
}
}
static void status_io_full ( enum log_level iodir , const char * who , const u8 * p )
static void status_io_full ( enum log_level iodir ,
const struct node_id * peer ,
const char * who , const u8 * p )
{
status_send ( take ( towire_status_io ( NULL , iodir , who , p ) ) ) ;
status_send ( take ( towire_status_io ( NULL , iodir , peer , who , p ) ) ) ;
}
static void status_peer_io_short ( enum log_level iodir , const u8 * p )
static void status_peer_io_short ( enum log_level iodir ,
const struct node_id * peer ,
const u8 * p )
{
status_debug ( " %s %s " ,
iodir = = LOG_IO_OUT ? " peer_out " : " peer_in " ,
wire_type_name ( fromwire_peektype ( p ) ) ) ;
status_peer_ debug ( peer , " %s %s " ,
iodir = = LOG_IO_OUT ? " peer_out " : " peer_in " ,
wire_type_name ( fromwire_peektype ( p ) ) ) ;
}
void status_peer_io ( enum log_level iodir , const u8 * p )
void status_peer_io ( enum log_level iodir ,
const struct node_id * peer ,
const u8 * p )
{
report_logging_io ( " SIGUSR1 " ) ;
if ( logging_io )
status_io_full ( iodir , " " , p ) ;
status_io_full ( iodir , NULL , " " , p ) ;
/* We get a huge amount of gossip; don't log it */
else if ( ! is_msg_for_gossipd ( p ) )
status_peer_io_short ( iodir , p ) ;
status_peer_io_short ( iodir , peer , p ) ;
}
void status_io ( enum log_level iodir , const char * who ,
void status_io ( enum log_level iodir ,
const struct node_id * peer ,
const char * who ,
const void * data , size_t len )
{
report_logging_io ( " SIGUSR1 " ) ;
if ( ! logging_io )
return ;
/* Horribly inefficient, but so is logging IO generally. */
status_io_full ( iodir , who , tal_dup_arr ( tmpctx , u8 , data , len , 0 ) ) ;
status_io_full ( iodir , peer , who , tal_dup_arr ( tmpctx , u8 , data , len , 0 ) ) ;
}
void status_vfmt ( enum log_level level , const char * fmt , va_list ap )
void status_vfmt ( enum log_level level ,
const struct node_id * peer ,
const char * fmt , va_list ap )
{
char * str ;
@ -146,16 +156,18 @@ void status_vfmt(enum log_level level, const char *fmt, va_list ap)
}
}
str = tal_vfmt ( NULL , fmt , ap ) ;
status_send ( take ( towire_status_log ( NULL , level , str ) ) ) ;
status_send ( take ( towire_status_log ( NULL , level , peer , str ) ) ) ;
tal_free ( str ) ;
}
void status_fmt ( enum log_level level , const char * fmt , . . . )
void status_fmt ( enum log_level level ,
const struct node_id * peer ,
const char * fmt , . . . )
{
va_list ap ;
va_start ( ap , fmt ) ;
status_vfmt ( level , fmt , ap ) ;
status_vfmt ( level , peer , fmt , ap ) ;
va_end ( ap ) ;
}