@@ -151,7 +151,7 @@ impl Log for AndroidLogger {
151
151
152
152
// If no tag was specified, use module name
153
153
let custom_tag = & config. tag ;
154
- let tag = custom_tag. as_ref ( ) . map ( |s| s. as_bytes ( ) ) . unwrap_or ( module_path. as_bytes ( ) ) ;
154
+ let tag = custom_tag. as_ref ( ) . map ( |s| s. as_bytes ( ) ) . unwrap_or_else ( || module_path. as_bytes ( ) ) ;
155
155
156
156
// truncate the tag here to fit into LOGGING_TAG_MAX_LEN
157
157
self . fill_tag_bytes ( & mut tag_bytes, tag) ;
@@ -202,24 +202,14 @@ impl AndroidLogger {
202
202
}
203
203
204
204
/// Filter for android logger.
205
+ #[ derive( Default ) ]
205
206
pub struct Config {
206
207
log_level : Option < Level > ,
207
208
filter : Option < env_logger:: filter:: Filter > ,
208
209
tag : Option < CString > ,
209
210
custom_format : Option < FormatFn > ,
210
211
}
211
212
212
- impl Default for Config {
213
- fn default ( ) -> Self {
214
- Config {
215
- log_level : None ,
216
- filter : None ,
217
- tag : None ,
218
- custom_format : None ,
219
- }
220
- }
221
- }
222
-
223
213
impl Config {
224
214
/// Change the minimum log level.
225
215
///
@@ -232,7 +222,7 @@ impl Config {
232
222
233
223
fn filter_matches ( & self , record : & Record ) -> bool {
234
224
if let Some ( ref filter) = self . filter {
235
- filter. matches ( & record)
225
+ filter. matches ( record)
236
226
} else {
237
227
true
238
228
}
@@ -361,7 +351,7 @@ impl<'a> PlatformLogWriter<'a> {
361
351
362
352
/// Copy `len` bytes from `index` position to starting position.
363
353
fn copy_bytes_to_start ( & mut self , index : usize , len : usize ) {
364
- let src = unsafe { self . buffer . as_ptr ( ) . offset ( index as isize ) } ;
354
+ let src = unsafe { self . buffer . as_ptr ( ) . add ( index) } ;
365
355
let dst = self . buffer . as_mut_ptr ( ) ;
366
356
unsafe { ptr:: copy ( src, dst, len) } ;
367
357
}
@@ -524,7 +514,7 @@ mod tests {
524
514
fn platform_log_writer_init_values ( ) {
525
515
let tag = CStr :: from_bytes_with_nul ( b"tag\0 " ) . unwrap ( ) ;
526
516
527
- let writer = PlatformLogWriter :: new ( Level :: Warn , & tag) ;
517
+ let writer = PlatformLogWriter :: new ( Level :: Warn , tag) ;
528
518
529
519
assert_eq ! ( writer. tag, tag) ;
530
520
// Android uses LogPriority instead, which doesn't implement equality checks
@@ -623,6 +613,6 @@ mod tests {
623
613
}
624
614
625
615
fn get_tag_writer ( ) -> PlatformLogWriter < ' static > {
626
- PlatformLogWriter :: new ( Level :: Warn , & CStr :: from_bytes_with_nul ( b"tag\0 " ) . unwrap ( ) )
616
+ PlatformLogWriter :: new ( Level :: Warn , CStr :: from_bytes_with_nul ( b"tag\0 " ) . unwrap ( ) )
627
617
}
628
618
}
0 commit comments