Skip to content

Commit

Permalink
force inline on needed functions for smaller binary size (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
chidea authored Feb 25, 2023
1 parent f71aa71 commit 162b362
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "console_log"
version = "0.2.0"
version = "0.2.1"
authors = ["Matthew Nicholson <matt@matt-land.com>"]
edition = "2018"
keywords = ["log", "logging", "console", "web_sys", "wasm"]
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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"))]
{
Expand Down Expand Up @@ -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());
Expand All @@ -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)
}

0 comments on commit 162b362

Please sign in to comment.