Skip to content

Commit

Permalink
Merge pull request #72 from rust-mobile/remove-once-cell
Browse files Browse the repository at this point in the history
remove once_cell as dependency
  • Loading branch information
Dushistov authored Jun 15, 2024
2 parents 772434e + e5f0e39 commit 7975f2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "android_logger"
version = "0.13.3"
version = "0.14.0"
authors = ["The android_logger Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand All @@ -17,9 +17,7 @@ default = ["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"
Expand Down
11 changes: 5 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@

#[cfg(target_os = "android")]
extern crate android_log_sys as log_ffi;
use once_cell::sync::OnceCell;

use log::{Level, LevelFilter, Log, Metadata, Record};
#[cfg(target_os = "android")]
Expand All @@ -74,9 +73,9 @@ use std::ffi::{CStr, CString};
use std::fmt;
use std::mem::{self, MaybeUninit};
use std::ptr;
use std::sync::OnceLock;

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 @@ -162,14 +161,14 @@ fn android_log(_buf_id: Option<LogId>, _priority: Level, _tag: &CStr, _msg: &CSt

/// Underlying android logger backend
pub struct AndroidLogger {
config: OnceCell<Config>,
config: OnceLock<Config>,
}

impl AndroidLogger {
/// Create new logger instance from config
pub fn new(config: Config) -> AndroidLogger {
AndroidLogger {
config: OnceCell::from(config),
config: OnceLock::from(config),
}
}

Expand All @@ -178,7 +177,7 @@ impl AndroidLogger {
}
}

static ANDROID_LOGGER: OnceCell<AndroidLogger> = OnceCell::new();
static ANDROID_LOGGER: OnceLock<AndroidLogger> = OnceLock::new();

const LOGGING_TAG_MAX_LEN: usize = 23;
const LOGGING_MSG_MAX_LEN: usize = 4000;
Expand All @@ -187,7 +186,7 @@ impl Default for AndroidLogger {
/// Create a new logger with default config
fn default() -> AndroidLogger {
AndroidLogger {
config: OnceCell::from(Config::default()),
config: OnceLock::from(Config::default()),
}
}
}
Expand Down

0 comments on commit 7975f2c

Please sign in to comment.