@@ -95,9 +95,9 @@ unsafe impl<'a> Feature for Log<'a> {
95
95
// So, at this time, i just giving access to it instanciation class
96
96
unsafe fn from_feature_ptr ( feature : * const c_void , class : ThreadingClass ) -> Option < Self > {
97
97
if class == ThreadingClass :: Instantiation {
98
- ( feature as * const lv2_sys:: LV2_Log_Log )
99
- . as_ref ( )
100
- . map ( |internal| Self { internal } )
98
+ ( feature as * const lv2_sys:: LV2_Log_Log )
99
+ . as_ref ( )
100
+ . map ( |internal| Self { internal } )
101
101
} else {
102
102
panic ! ( "The log feature is only allowed in the indtantiation threading class" ) ;
103
103
}
@@ -107,7 +107,7 @@ unsafe impl<'a> Feature for Log<'a> {
107
107
impl < ' a > Log < ' a > {
108
108
/// Send a log message to the host.
109
109
///
110
- /// the `entry_type` parameter is an URID representing the kind of log message. There are four
110
+ /// The `entry_type` parameter is an URID representing the kind of log message. There are four
111
111
/// kind of message:
112
112
/// * **note:** an informative message.
113
113
/// * **warning:** a warning message.
@@ -122,24 +122,40 @@ impl<'a> Log<'a> {
122
122
} else {
123
123
return Err ( LogError :: NoCallback ) ;
124
124
} ;
125
- //checking for null terminator
126
- let mut have_null = false ;
127
- for b in message. bytes ( ) {
128
- if b == b'\0' {
129
- have_null = true ;
130
- break ;
131
- }
132
- }
133
- if !have_null {
134
- return Err ( LogError :: NoNullTerminator ) ;
125
+ let message = String :: from ( message) + "\0 " ;
126
+
127
+ let res = unsafe {
128
+ ( printf) (
129
+ self . internal . handle ,
130
+ entry_type. get ( ) ,
131
+ "%s\0 " as * const _ as * const c_char ,
132
+ message. as_str ( ) as * const _ as * const c_char ,
133
+ )
134
+ } ;
135
+ if res > 0 {
136
+ Ok ( ( ) )
137
+ } else {
138
+ Err ( LogError :: PrintError )
135
139
}
140
+ }
141
+ /// Send a message to the host with a new line at the end.
142
+ ///
143
+ /// It same as [print](struct.Log.html#method.print) but add a newline a the end of message.
144
+ /// See [print](struct.Log.html#method.print) documentation for details.
145
+ pub fn println ( & self , entry_type : impl EntryType , message : & str ) -> Result < ( ) , LogError > {
146
+ let printf = if let Some ( printf) = self . internal . printf {
147
+ printf
148
+ } else {
149
+ return Err ( LogError :: NoCallback ) ;
150
+ } ;
151
+ let message = String :: from ( message) + "\n \0 " ;
136
152
137
153
let res = unsafe {
138
154
( printf) (
139
155
self . internal . handle ,
140
156
entry_type. get ( ) ,
141
157
"%s\0 " as * const _ as * const c_char ,
142
- message as * const _ as * const c_char ,
158
+ message. as_str ( ) as * const _ as * const c_char ,
143
159
)
144
160
} ;
145
161
if res > 0 {
0 commit comments