Skip to content

Commit 2353c21

Browse files
committed
lightningd: don't allocate to print node_id for logging.
Signed-off-by: Rusty Russell <[email protected]>
1 parent c520ab1 commit 2353c21

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lightningd/log.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void log_to_files(const char *log_prefix,
207207
struct log_file **log_files)
208208
{
209209
char tstamp[sizeof("YYYY-mm-ddTHH:MM:SS.nnnZ ")];
210-
char *entry, *nodestr;
210+
char *entry, nodestr[hex_str_size(PUBKEY_CMPR_LEN)];
211211
bool filtered;
212212

213213
if (print_timestamps) {
@@ -218,9 +218,10 @@ static void log_to_files(const char *log_prefix,
218218
tstamp[0] = '\0';
219219

220220
if (node_id)
221-
nodestr = fmt_node_id(tmpctx, node_id);
221+
hex_encode(node_id->k, sizeof(node_id->k),
222+
nodestr, sizeof(nodestr));
222223
else
223-
nodestr = "";
224+
nodestr[0] = '\0';
224225
if (level == LOG_IO_IN || level == LOG_IO_OUT) {
225226
const char *dir = level == LOG_IO_IN ? "[IN]" : "[OUT]";
226227
char *hex = tal_hexstr(NULL, io, io_len);

0 commit comments

Comments
 (0)