mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-23 00:44:26 +01:00
Add global SDK logger (#242)
* Add SDK global logger * Add bindings * Fix path to internal uniffi log * Exclude "set_log_stream" from generated RN methods * Move logger-specific structs to a separate module * Delegate init_logging to method in logger.rs * Rename uniffi BindingLogger to UniffiBindingLogger * Add set_log_stream for dart bindings * Add SDK logger to Dart bindings * Rename dart binding logger to DartBindingLogger * Add rustdocs * RN bindings: Add manual handling for setLogStream() * Re-generate dart bindings * Re-generate RN bindings * Remove LOG_INIT cell * Set global maximum log level once on initialization Return a LiquidSdkError::Generic instead of Anyhow error when initializing log stream on Dart bindings * Do not panic when initializing binding loggers * Rename LogStream to Logger --------- Co-authored-by: Erdem Yerebasmaz <erdem@yerebasmaz.com>
This commit is contained in:
@@ -23,6 +23,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_BindingLiquidSdkPtr => wire
|
||||
._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdkPtr;
|
||||
|
||||
@protected
|
||||
AnyhowException dco_decode_AnyhowException(dynamic raw);
|
||||
|
||||
@protected
|
||||
BindingLiquidSdk
|
||||
dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(
|
||||
@@ -40,6 +43,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
RustStreamSink<LiquidSdkEvent> dco_decode_StreamSink_liquid_sdk_event_Dco(dynamic raw);
|
||||
|
||||
@protected
|
||||
RustStreamSink<LogEntry> dco_decode_StreamSink_log_entry_Dco(dynamic raw);
|
||||
|
||||
@protected
|
||||
String dco_decode_String(dynamic raw);
|
||||
|
||||
@@ -112,6 +118,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
LNInvoice dco_decode_ln_invoice(dynamic raw);
|
||||
|
||||
@protected
|
||||
LogEntry dco_decode_log_entry(dynamic raw);
|
||||
|
||||
@protected
|
||||
Network dco_decode_network(dynamic raw);
|
||||
|
||||
@@ -175,6 +184,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
BigInt dco_decode_usize(dynamic raw);
|
||||
|
||||
@protected
|
||||
AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
BindingLiquidSdk
|
||||
sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(
|
||||
@@ -192,6 +204,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
RustStreamSink<LiquidSdkEvent> sse_decode_StreamSink_liquid_sdk_event_Dco(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
RustStreamSink<LogEntry> sse_decode_StreamSink_log_entry_Dco(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
String sse_decode_String(SseDeserializer deserializer);
|
||||
|
||||
@@ -264,6 +279,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
LNInvoice sse_decode_ln_invoice(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
LogEntry sse_decode_log_entry(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
Network sse_decode_network(SseDeserializer deserializer);
|
||||
|
||||
@@ -327,6 +345,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
BigInt sse_decode_usize(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> cst_encode_AnyhowException(AnyhowException raw) {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@protected
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> cst_encode_StreamSink_liquid_sdk_event_Dco(
|
||||
RustStreamSink<LiquidSdkEvent> raw) {
|
||||
@@ -335,6 +359,14 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
codec: DcoCodec(decodeSuccessData: dco_decode_liquid_sdk_event, decodeErrorData: null)));
|
||||
}
|
||||
|
||||
@protected
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> cst_encode_StreamSink_log_entry_Dco(
|
||||
RustStreamSink<LogEntry> raw) {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
return cst_encode_String(raw.setupAndSerialize(
|
||||
codec: DcoCodec(decodeSuccessData: dco_decode_log_entry, decodeErrorData: null)));
|
||||
}
|
||||
|
||||
@protected
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> cst_encode_String(String raw) {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
@@ -641,6 +673,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
wireObj.min_final_cltv_expiry_delta = cst_encode_u_64(apiObj.minFinalCltvExpiryDelta);
|
||||
}
|
||||
|
||||
@protected
|
||||
void cst_api_fill_to_wire_log_entry(LogEntry apiObj, wire_cst_log_entry wireObj) {
|
||||
wireObj.line = cst_encode_String(apiObj.line);
|
||||
wireObj.level = cst_encode_String(apiObj.level);
|
||||
}
|
||||
|
||||
@protected
|
||||
void cst_api_fill_to_wire_payment(Payment apiObj, wire_cst_payment wireObj) {
|
||||
wireObj.tx_id = cst_encode_String(apiObj.txId);
|
||||
@@ -823,6 +861,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
void cst_encode_unit(void raw);
|
||||
|
||||
@protected
|
||||
void sse_encode_AnyhowException(AnyhowException self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(
|
||||
BindingLiquidSdk self, SseSerializer serializer);
|
||||
@@ -839,6 +880,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
void sse_encode_StreamSink_liquid_sdk_event_Dco(
|
||||
RustStreamSink<LiquidSdkEvent> self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_StreamSink_log_entry_Dco(RustStreamSink<LogEntry> self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_String(String self, SseSerializer serializer);
|
||||
|
||||
@@ -911,6 +955,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
void sse_encode_ln_invoice(LNInvoice self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_log_entry(LogEntry self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_network(Network self, SseSerializer serializer);
|
||||
|
||||
@@ -1229,6 +1276,22 @@ class RustLibWire implements BaseWire {
|
||||
late final _wire__crate__bindings__BindingLiquidSdk_sync =
|
||||
_wire__crate__bindings__BindingLiquidSdk_syncPtr.asFunction<void Function(int, int)>();
|
||||
|
||||
void wire__crate__bindings__breez_log_stream(
|
||||
int port_,
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> s,
|
||||
) {
|
||||
return _wire__crate__bindings__breez_log_stream(
|
||||
port_,
|
||||
s,
|
||||
);
|
||||
}
|
||||
|
||||
late final _wire__crate__bindings__breez_log_streamPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>(
|
||||
'frbgen_breez_liquid_wire__crate__bindings__breez_log_stream');
|
||||
late final _wire__crate__bindings__breez_log_stream = _wire__crate__bindings__breez_log_streamPtr
|
||||
.asFunction<void Function(int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
|
||||
|
||||
void wire__crate__bindings__connect(
|
||||
int port_,
|
||||
ffi.Pointer<wire_cst_connect_request> req,
|
||||
@@ -1697,6 +1760,12 @@ final class wire_cst_ln_invoice extends ffi.Struct {
|
||||
external int min_final_cltv_expiry_delta;
|
||||
}
|
||||
|
||||
final class wire_cst_log_entry extends ffi.Struct {
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> line;
|
||||
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> level;
|
||||
}
|
||||
|
||||
final class wire_cst_PaymentError_Generic extends ffi.Struct {
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user