docs(logger): setup_logger safety assumptions (#107)
This commit is contained in:
committed by
GitHub
parent
8b4602c62f
commit
2dd30931f2
@@ -25,9 +25,15 @@ use std::path::Path;
|
||||
use utils::setup_logger;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
// This depends on `clap`
|
||||
let opts = Opts::parse();
|
||||
|
||||
setup_logger(opts.debug);
|
||||
// SAFETY:
|
||||
// We are assuming the entire process is single-threaded
|
||||
// at this point.
|
||||
// This seems true for the current version of `clap`,
|
||||
// but there's no guarantee for future updates
|
||||
unsafe { setup_logger(opts.debug) };
|
||||
|
||||
// Directly handling methods / commands that aren't linked to [`ADBDeviceExt`] trait.
|
||||
// Other methods just have to create a concrete [`ADBDeviceExt`] instance, and return it.
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
pub fn setup_logger(debug: bool) {
|
||||
/// # Safety
|
||||
///
|
||||
/// This conditionally mutates the process' environment.
|
||||
/// See [`std::env::set_var`] for more info.
|
||||
pub unsafe fn setup_logger(debug: bool) {
|
||||
// RUST_LOG variable has more priority then "--debug" flag
|
||||
if std::env::var("RUST_LOG").is_err() {
|
||||
let level = match debug {
|
||||
|
||||
Reference in New Issue
Block a user