X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=inline;f=lightning-c-bindings%2Fsrc%2Flightning%2Futil%2Flogger.rs;h=7aa67a2e41f3e13c4a91cfd7cdce51eeba1e3201;hb=4ed52804d3cd73f05bba6a705528d0d43495aa88;hp=dc67386841c02ff3ba070e18694ed92dddadb497;hpb=2c56d2b4709d39d5e96ec84e4ecb07f9ebed0387;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/util/logger.rs b/lightning-c-bindings/src/lightning/util/logger.rs index dc67386..7aa67a2 100644 --- a/lightning-c-bindings/src/lightning/util/logger.rs +++ b/lightning-c-bindings/src/lightning/util/logger.rs @@ -15,6 +15,7 @@ use std::str::FromStr; use std::ffi::c_void; +use core::convert::Infallible; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -82,6 +83,26 @@ impl Level { pub extern "C" fn Level_clone(orig: &Level) -> Level { orig.clone() } +#[no_mangle] +/// Utility method to constructs a new Trace-variant Level +pub extern "C" fn Level_trace() -> Level { + Level::Trace} +#[no_mangle] +/// Utility method to constructs a new Debug-variant Level +pub extern "C" fn Level_debug() -> Level { + Level::Debug} +#[no_mangle] +/// Utility method to constructs a new Info-variant Level +pub extern "C" fn Level_info() -> Level { + Level::Info} +#[no_mangle] +/// Utility method to constructs a new Warn-variant Level +pub extern "C" fn Level_warn() -> Level { + Level::Warn} +#[no_mangle] +/// Utility method to constructs a new Error-variant Level +pub extern "C" fn Level_error() -> Level { + Level::Error} /// Checks if two Levels contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -119,6 +140,14 @@ pub struct Logger { } unsafe impl Send for Logger {} unsafe impl Sync for Logger {} +#[no_mangle] +pub(crate) extern "C" fn Logger_clone_fields(orig: &Logger) -> Logger { + Logger { + this_arg: orig.this_arg, + log: Clone::clone(&orig.log), + free: Clone::clone(&orig.free), + } +} use lightning::util::logger::Logger as rustLogger; impl rustLogger for Logger {