Skip to content

Commit 162b362

Browse files
authored
force inline on needed functions for smaller binary size (#10)
1 parent f71aa71 commit 162b362

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "console_log"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
authors = ["Matthew Nicholson <matt@matt-land.com>"]
55
edition = "2018"
66
keywords = ["log", "logging", "console", "web_sys", "wasm"]

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ static LOGGER: WebConsoleLogger = WebConsoleLogger {};
115115
struct WebConsoleLogger {}
116116

117117
impl Log for WebConsoleLogger {
118+
#[inline]
118119
fn enabled(&self, metadata: &Metadata) -> bool {
119120
metadata.level() <= log::max_level()
120121
}
@@ -141,6 +142,7 @@ impl Log for WebConsoleLogger {
141142
/// .chain(fern::Output::call(console_log::log))
142143
/// .apply()?;
143144
/// ```
145+
#[cfg_attr(not(feature = "color"), inline)]
144146
pub fn log(record: &Record) {
145147
#[cfg(not(feature = "color"))]
146148
{
@@ -208,6 +210,7 @@ pub fn log(record: &Record) {
208210
/// console_log::init_with_level(Level::Debug).expect("error initializing logger");
209211
/// }
210212
/// ```
213+
#[inline]
211214
pub fn init_with_level(level: Level) -> Result<(), SetLoggerError> {
212215
log::set_logger(&LOGGER)?;
213216
log::set_max_level(level.to_level_filter());
@@ -223,6 +226,7 @@ pub fn init_with_level(level: Level) -> Result<(), SetLoggerError> {
223226
/// console_log::init().expect("error initializing logger");
224227
/// }
225228
/// ```
229+
#[inline]
226230
pub fn init() -> Result<(), SetLoggerError> {
227231
init_with_level(Level::Info)
228232
}

0 commit comments

Comments
 (0)