reexport WASM_LOG_ENV_NAME

This commit is contained in:
vms 2020-12-09 11:34:39 +03:00
parent c90b685238
commit b631dab17f
4 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "fluence"
version = "0.2.9" # remember to update html_root_url
version = "0.2.10" # remember to update html_root_url
description = "Fluence backend SDK for developing backend applications for the Fluence network"
documentation = "https://docs.rs/fluence/"
repository = "https://github.com/fluencelabs/rust-sdk"

View File

@ -48,6 +48,8 @@ pub use export_allocator::deallocate;
pub use logger::WasmLoggerBuilder;
#[cfg(feature = "logger")]
pub use logger::TargetMap;
#[cfg(feature = "logger")]
pub use logger::WASM_LOG_ENV_NAME;
pub use result::get_result_ptr;
pub use result::get_result_size;

View File

@ -44,6 +44,12 @@
use log::Level as LogLevel;
/// By default, logger will be initialized with log level from this environment variable.
pub const WASM_LOG_ENV_NAME: &'static str = "WASM_LOG";
/// If WASM_LOG_ENV isn't set, then this level will be used as the default.
const WASM_DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Info;
pub type TargetMap = std::collections::HashMap<&'static str, i64>;
/// The Wasm Logger.
@ -75,15 +81,10 @@ impl WasmLoggerBuilder {
pub fn new() -> Self {
use std::str::FromStr;
const WASM_LOG_ENV_NAME: &'static str = "WASM_LOG";
const RUST_DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Info;
let log_level = match std::env::var(WASM_LOG_ENV_NAME) {
Ok(log_level_str) => {
LogLevel::from_str(&log_level_str).unwrap_or(RUST_DEFAULT_LOG_LEVEL)
}
Err(_) => RUST_DEFAULT_LOG_LEVEL,
};
let log_level = std::env::var(WASM_LOG_ENV_NAME)
.map_or(WASM_DEFAULT_LOG_LEVEL, |log_level_str| {
LogLevel::from_str(&log_level_str).unwrap_or(WASM_DEFAULT_LOG_LEVEL)
});
Self {
log_level,

View File

@ -55,7 +55,7 @@
//! pub fn curl_get(url: String) -> String;
//! }
//! ```
#![doc(html_root_url = "https://docs.rs/fluence/0.2.9")]
#![doc(html_root_url = "https://docs.rs/fluence/0.2.10")]
#![deny(
dead_code,
nonstandard_style,