Skip to content

Commit

Permalink
Update env_logger to 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab committed Mar 4, 2024
1 parent cf2684e commit 84c7657
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ A logging implementation for `log` which hooks to android log output.
"""
keywords = ["android", "bindings", "log", "logger"]
categories = ["api-bindings"]
edition = "2021"

[features]
default = ["regex"]
regex = ["env_logger/regex"]
regex = ["env_filter/regex"]

[dependencies]
once_cell = "1.9"
env_filter = "0.1.0"
env_logger = "0.11.2"

[dependencies.log]
version = "0.4"

[dependencies.android_log-sys]
version = "0.3"

[dependencies.env_logger]
version = "0.10"
default-features = false
15 changes: 5 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@
#[cfg(target_os = "android")]
extern crate android_log_sys as log_ffi;
extern crate once_cell;
use once_cell::sync::OnceCell;
#[macro_use]
extern crate log;

extern crate env_logger;

use log::{Level, LevelFilter, Log, Metadata, Record};
#[cfg(target_os = "android")]
Expand All @@ -80,7 +75,7 @@ use std::fmt;
use std::mem::{self, MaybeUninit};
use std::ptr;

pub use env_logger::filter::{Builder as FilterBuilder, Filter};
pub use env_filter::{Builder as FilterBuilder, Filter};
pub use env_logger::fmt::Formatter;

pub(crate) type FormatFn = Box<dyn Fn(&mut dyn fmt::Write, &Record) -> fmt::Result + Sync + Send>;
Expand Down Expand Up @@ -280,7 +275,7 @@ impl AndroidLogger {
pub struct Config {
log_level: Option<LevelFilter>,
buf_id: Option<LogId>,
filter: Option<env_logger::filter::Filter>,
filter: Option<env_filter::Filter>,
tag: Option<CString>,
custom_format: Option<FormatFn>,
}
Expand Down Expand Up @@ -318,7 +313,7 @@ impl Config {
}
}

pub fn with_filter(mut self, filter: env_logger::filter::Filter) -> Self {
pub fn with_filter(mut self, filter: env_filter::Filter) -> Self {
self.filter = Some(filter);
self
}
Expand Down Expand Up @@ -538,7 +533,7 @@ pub fn init_once(config: Config) {
let logger = ANDROID_LOGGER.get_or_init(|| AndroidLogger::new(config));

if let Err(err) = log::set_logger(logger) {
debug!("android_logger: log::set_logger failed: {}", err);
log::debug!("android_logger: log::set_logger failed: {}", err);
} else if let Some(level) = log_level {
log::set_max_level(level);
}
Expand Down Expand Up @@ -601,7 +596,7 @@ mod tests {
let info_record = Record::builder().level(Level::Info).build();
let debug_record = Record::builder().level(Level::Debug).build();

let info_all_filter = env_logger::filter::Builder::new().parse("info").build();
let info_all_filter = env_filter::Builder::new().parse("info").build();
let info_all_config = Config::default().with_filter(info_all_filter);

assert!(info_all_config.filter_matches(&info_record));
Expand Down

0 comments on commit 84c7657

Please sign in to comment.