Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a quick_main! variant #29

Open
jonasbb opened this issue Apr 23, 2019 · 0 comments
Open

Add a quick_main! variant #29

jonasbb opened this issue Apr 23, 2019 · 0 comments

Comments

@jonasbb
Copy link
Owner

jonasbb commented Apr 23, 2019

See quick_main! in error-chain.

  1. Print errors:
fn main() {
    use std::io::{self, Write};

    if let Err(err) = run() {
        let stderr = io::stderr();
        let mut out = stderr.lock();
        // cannot handle a write error here, we are already in the outermost layer
        let _ = writeln!(out, "An error occured:");
        for fail in err.iter_chain() {
            let _ = writeln!(out, "  {}", fail);
        }
        let _ = writeln!(out, "{}", err.backtrace());
        std::process::exit(1);
    }
}
  1. Setup libraries
    • env_logger: Either generic or custom:
    let log_settings = "client=debug,tlsproxy=debug";
    env_logger::Builder::from_env(env_logger::Env::default().default_filter_or(log_settings))
        .default_format_timestamp_nanos(true)
        .init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant