From: Carl Lerche Date: Thu, 22 May 2014 21:03:56 +0000 (-0700) Subject: Start adding logging in cargo command X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~1053 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=92b449b6444718c5621b059f265abbe31ca4a80a;p=cargo.git Start adding logging in cargo command --- diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 800c84864..db3558616 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -1,8 +1,12 @@ +#![feature(phase)] + extern crate cargo; extern crate toml; extern crate hammer; extern crate serialize; extern crate collections; +#[phase(syntax, link)] +extern crate log; use hammer::{FlagConfig,FlagConfiguration}; use std::os; @@ -27,14 +31,30 @@ struct ProjectLocation { on this top-level information. */ fn execute() { + debug!("executing; cmd=cargo; args={}", os::args()); + let (cmd, _) = match process(os::args()) { Ok((cmd, args)) => (cmd, args), Err(err) => return handle_error(err) }; - if cmd == "config-for-key".to_strbuf() { execute_main_without_stdin(config_for_key) } - else if cmd == "config-list".to_strbuf() { execute_main_without_stdin(config_list) } - else if cmd == "locate-project".to_strbuf() { execute_main_without_stdin(locate_project) } + if cmd == "config-for-key".to_strbuf() { + log!(4, "cmd == config-for-key"); + execute_main_without_stdin(config_for_key) + } + else if cmd == "config-list".to_strbuf() { + log!(4, "cmd == config-list"); + execute_main_without_stdin(config_list) + } + else if cmd == "locate-project".to_strbuf() { + log!(4, "cmd == locate-project"); + execute_main_without_stdin(locate_project) + } + else { + // TODO: Handle automatic dispatching to cargo-* + debug!("unknown command"); + println!("Automatic execing of cargo-* commands has not yet been implemented. Call cargo-* commands directly for now"); + } } fn process(args: Vec<~str>) -> CLIResult<(StrBuf, Vec)> { diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 93ada512f..c497df809 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -2,7 +2,7 @@ #![crate_type="rlib"] #![allow(deprecated_owned_vector)] -#![feature(macro_rules)] +#![feature(macro_rules,phase)] extern crate collections; extern crate url; @@ -11,6 +11,9 @@ extern crate serialize; extern crate semver; extern crate toml; +#[phase(syntax, link)] +extern crate log; + #[cfg(test)] extern crate hamcrest; @@ -77,6 +80,8 @@ pub fn process_executed<'a, T: Encodable, io::IoError>>(result } pub fn handle_error(err: CLIError) { + log!(4, "handle_error; err={}", err); + let CLIError { msg, exit_code, .. } = err; let _ = write!(&mut std::io::stderr(), "{}", msg); //detail.map(|d| write!(&mut std::io::stderr(), ":\n{}", d));