-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mcu-util: better logs use color-eyre use RUST_LOG env variable when given fallback on INFO log level * mcu-util: remove some allow(dead_code)
- Loading branch information
Showing
12 changed files
with
26 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
use eyre::Result; | ||
use color_eyre::eyre::Result; | ||
use tracing::level_filters::LevelFilter; | ||
use tracing_subscriber::layer::SubscriberExt; | ||
use tracing_subscriber::util::SubscriberInitExt; | ||
use tracing_subscriber::Layer; | ||
use tracing_subscriber::{EnvFilter, Layer}; | ||
|
||
/// Initialize the logger | ||
pub fn init() -> Result<()> { | ||
let filter = EnvFilter::builder() | ||
.with_default_directive(LevelFilter::INFO.into()) | ||
.from_env_lossy(); | ||
|
||
fn try_init_stdout_logger(loglevel: tracing::Level) -> Result<()> { | ||
let stdout_log = tracing_subscriber::fmt::layer() | ||
.compact() | ||
.with_writer(std::io::stdout) | ||
.with_filter(LevelFilter::from_level(loglevel)); | ||
|
||
tracing_subscriber::registry().with(stdout_log).try_init()?; | ||
.with_filter(filter); | ||
|
||
Ok(()) | ||
} | ||
let registry = tracing_subscriber::registry(); | ||
#[cfg(tokio_unstable)] | ||
let registry = registry.with(console_subscriber::spawn()); | ||
registry.with(stdout_log).try_init()?; | ||
|
||
/// Initialize the logger | ||
pub fn init(loglevel: tracing::Level) -> Result<()> { | ||
try_init_stdout_logger(loglevel)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters