diff options
Diffstat (limited to 'src/output.rs')
-rw-r--r-- | src/output.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/output.rs b/src/output.rs index d7ab74e..0f0e4a9 100644 --- a/src/output.rs +++ b/src/output.rs @@ -39,6 +39,45 @@ impl BarbOutput { } } + #[cfg(test)] + pub fn quiet() -> BarbOutput { + BarbOutput { + request: false, + req_headers: false, + headers: false, + body: false, + raw_body: false, + color: false, + } + } + + pub fn req_dep(&self, method: String, url: String, code: u16, text: &str) { + if !self.request { + return; + } + if self.color { + if code >= 400 { + println!( + "{} {} {} {}", + code.to_string().red(), + text.red(), + method.red(), + url.red() + ); + } else { + println!( + "{} {} {} {}", + code.to_string().green(), + text, + method.purple(), + url.purple() + ); + } + } else { + println!("{} {} {} {}", code, text, method, url); + } + } + pub fn req(&self, method: String, url: String) { if !self.request { return; |