From f6b8321597aafec78234242edeea3f07501aa735 Mon Sep 17 00:00:00 2001 From: ChIdea Date: Wed, 8 Feb 2023 15:20:59 +0900 Subject: [PATCH] force inline on needed functions for smaller binary size --- Cargo.toml | 2 +- src/lib.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index df914ae..c590606 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "console_log" -version = "0.2.0" +version = "0.2.1" authors = ["Matthew Nicholson "] edition = "2018" keywords = ["log", "logging", "console", "web_sys", "wasm"] diff --git a/src/lib.rs b/src/lib.rs index efbb8cd..dcd06e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -115,6 +115,7 @@ static LOGGER: WebConsoleLogger = WebConsoleLogger {}; struct WebConsoleLogger {} impl Log for WebConsoleLogger { + #[inline] fn enabled(&self, metadata: &Metadata) -> bool { metadata.level() <= log::max_level() } @@ -141,6 +142,7 @@ impl Log for WebConsoleLogger { /// .chain(fern::Output::call(console_log::log)) /// .apply()?; /// ``` +#[cfg_attr(not(feature = "color"), inline)] pub fn log(record: &Record) { #[cfg(not(feature = "color"))] { @@ -208,6 +210,7 @@ pub fn log(record: &Record) { /// console_log::init_with_level(Level::Debug).expect("error initializing logger"); /// } /// ``` +#[inline] pub fn init_with_level(level: Level) -> Result<(), SetLoggerError> { log::set_logger(&LOGGER)?; log::set_max_level(level.to_level_filter()); @@ -223,6 +226,7 @@ pub fn init_with_level(level: Level) -> Result<(), SetLoggerError> { /// console_log::init().expect("error initializing logger"); /// } /// ``` +#[inline] pub fn init() -> Result<(), SetLoggerError> { init_with_level(Level::Info) }