@@ -15,14 +15,29 @@ pub use lightning::util::logger::Level as LogLevel;
1515use chrono:: Utc ;
1616use log:: { debug, error, info, trace, warn} ;
1717
18+ #[ cfg( not( feature = "uniffi" ) ) ]
19+ use core:: fmt;
1820use std:: fmt:: Debug ;
1921use std:: fs;
2022use std:: io:: Write ;
2123use std:: path:: Path ;
2224use std:: sync:: Arc ;
2325
24- /// A unit of logging output with Metadata to enable filtering Module_path ,
26+ /// A unit of logging output with Metadata to enable filtering module_path ,
2527/// file, line to inform on log's source.
28+ #[ cfg( not( feature = "uniffi" ) ) ]
29+ pub struct LogRecord < ' a > {
30+ /// The verbosity level of the message.
31+ pub level : LogLevel ,
32+ /// The message body.
33+ pub args : fmt:: Arguments < ' a > ,
34+ /// The module path of the message.
35+ pub module_path : & ' a str ,
36+ /// The line containing the message.
37+ pub line : u32 ,
38+ }
39+
40+ #[ cfg( feature = "uniffi" ) ]
2641pub struct LogRecord {
2742 /// The verbosity level of the message.
2843 pub level : LogLevel ,
@@ -34,6 +49,7 @@ pub struct LogRecord {
3449 pub line : u32 ,
3550}
3651
52+ #[ cfg( feature = "uniffi" ) ]
3753impl < ' a > From < Record < ' a > > for LogRecord {
3854 fn from ( record : Record ) -> Self {
3955 Self {
@@ -45,8 +61,27 @@ impl<'a> From<Record<'a>> for LogRecord {
4561 }
4662}
4763
64+ #[ cfg( not( feature = "uniffi" ) ) ]
65+ impl < ' a > From < Record < ' a > > for LogRecord < ' a > {
66+ fn from ( record : Record < ' a > ) -> Self {
67+ Self {
68+ level : record. level ,
69+ args : record. args ,
70+ module_path : record. module_path ,
71+ line : record. line ,
72+ }
73+ }
74+ }
75+
4876/// LogWriter trait encapsulating the operations required of a
4977/// logger's writer.
78+ #[ cfg( not( feature = "uniffi" ) ) ]
79+ pub trait LogWriter : Send + Sync + Debug {
80+ /// Log the record.
81+ fn log < ' a > ( & self , record : LogRecord < ' a > ) ;
82+ }
83+
84+ #[ cfg( feature = "uniffi" ) ]
5085pub trait LogWriter : Send + Sync + Debug {
5186 /// Log the record.
5287 fn log ( & self , record : LogRecord ) ;
0 commit comments