Move src/logger.rs into logger/ crate to unify logging across the workspace
This commit is contained in:
15
logger/Cargo.toml
Normal file
15
logger/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "solana-logger"
|
||||
version = "0.11.0"
|
||||
description = "Solana Logger"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://solana.com/"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.6.0"
|
||||
|
||||
[lib]
|
||||
name = "solana_logger"
|
16
logger/src/lib.rs
Normal file
16
logger/src/lib.rs
Normal file
@ -0,0 +1,16 @@
|
||||
//! The `logger` module provides a setup function for `env_logger`. Its only function,
|
||||
//! `setup()` may be called multiple times.
|
||||
|
||||
use env_logger;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
static INIT: Once = ONCE_INIT;
|
||||
|
||||
/// Setup function that is only run once, even if called multiple times.
|
||||
pub fn setup() {
|
||||
INIT.call_once(|| {
|
||||
env_logger::Builder::from_default_env()
|
||||
.default_format_timestamp_nanos(true)
|
||||
.init();
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user