-
-
Save durka/79d62fbc3b1688e998610429b0fa60bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
extern crate failure; | |
use failure::Error; | |
use failure::Fail; | |
use failure::ResultExt; | |
fn logging() -> Result<(), Error> { | |
let log_level = env::var("LOG_LEVEL") | |
.unwrap_or_else(|e| match e { | |
VarError::NotPresent => "".to_owned(), | |
s @ VarError::NotUnicode(_) => s.downcast::<VarError>().context("'LOG_LEVEL' not UTF-8 | |
compatible!")? | |
}); | |
} | |
fn main() { | |
logging().unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment