Browse Source

daemon: add helper to log hex.

Good for keys; eventually we'll want to log structures by type though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
29c8611e53
  1. 7
      daemon/log.c
  2. 1
      daemon/log.h

7
daemon/log.c

@ -262,6 +262,13 @@ void log_add(struct log *log, const char *fmt, ...)
va_end(ap);
}
void log_add_hex(struct log *log, const void *data, size_t len)
{
char hex[hex_str_size(len)];
hex_encode(data, len, hex, hex_str_size(len));
log_add(log, "%s", hex);
}
void log_each_line_(const struct log_record *lr,
void (*func)(unsigned int skipped,
struct timerel time,

1
daemon/log.h

@ -39,6 +39,7 @@ void log_io(struct log *log, bool in, const void *data, size_t len);
void log_(struct log *log, enum log_level level, const char *fmt, ...)
PRINTF_FMT(3,4);
void log_add(struct log *log, const char *fmt, ...) PRINTF_FMT(2,3);
void log_add_hex(struct log *log, const void *data, size_t len);
void logv(struct log *log, enum log_level level, const char *fmt, va_list ap);
#define log_add_struct(log, structtype, ptr) \

Loading…
Cancel
Save