From: Matt Corallo Date: Sun, 21 Nov 2021 18:46:53 +0000 (+0000) Subject: Update C/C++ demos to support new Logger API X-Git-Tag: v0.0.103.1^2~6 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=33381f620f00cff5200bba7eee72446f1619c629;p=ldk-c-bindings Update C/C++ demos to support new Logger API --- diff --git a/lightning-c-bindings/demo.c b/lightning-c-bindings/demo.c index e8a0997..dfa0e2f 100644 --- a/lightning-c-bindings/demo.c +++ b/lightning-c-bindings/demo.c @@ -4,8 +4,12 @@ #include #include -void print_log(const void *this_arg, const char *record) { - printf("%s", record); +void print_log(const void *this_arg, const LDKRecord *record) { + LDKStr mod = Record_get_module_path(record); + LDKStr str = Record_get_args(record); + printf("%.*s:%d - %.*s\n", (int)mod.len, mod.chars, Record_get_line(record), (int)str.len, str.chars); + Str_free(str); + Str_free(mod); } uint32_t get_fee(const void *this_arg, LDKConfirmationTarget target) { diff --git a/lightning-c-bindings/demo.cpp b/lightning-c-bindings/demo.cpp index 34c4dc9..6269249 100644 --- a/lightning-c-bindings/demo.cpp +++ b/lightning-c-bindings/demo.cpp @@ -98,8 +98,10 @@ const LDKThirtyTwoBytes genesis_hash = { // We don't care particularly if this i .data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1 } }; -void print_log(const void *this_arg, const char *record) { - printf("%p - %s\n", this_arg, record); +void print_log(const void *this_arg, const LDKRecord *record) { + LDK::Str mod = Record_get_module_path(record); + LDK::Str str = Record_get_args(record); + printf("%p - %.*s:%d - %.*s\n", this_arg, (int)mod->len, mod->chars, Record_get_line(record), (int)str->len, str->chars); } uint32_t get_fee(const void *this_arg, LDKConfirmationTarget target) {