Fix visibility Logger.

This commit is contained in:
jcamiel 2023-02-17 13:40:50 +01:00
parent daa5e5ebd4
commit 5b8a6fb95c
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
11 changed files with 15 additions and 46 deletions

View File

@ -27,7 +27,6 @@ pub use self::options::parse_options;
pub use self::options::{CliOptions, OutputType}; pub use self::options::{CliOptions, OutputType};
pub use self::variables::parse as parse_variable; pub use self::variables::parse as parse_variable;
pub use self::variables::parse_value as parse_variable_value; pub use self::variables::parse_value as parse_variable_value;
pub use crate::util::logger::Logger;
mod fs; mod fs;
pub mod interactive; pub mod interactive;

View File

@ -57,7 +57,7 @@ pub fn parse_value(s: &str) -> Result<Value, CliError> {
} }
#[cfg(test)] #[cfg(test)]
pub mod tests { mod tests {
use super::*; use super::*;
#[test] #[test]

View File

@ -29,8 +29,8 @@ use super::request::*;
use super::request_spec::*; use super::request_spec::*;
use super::response::*; use super::response::*;
use super::{Header, HttpError, Verbosity}; use super::{Header, HttpError, Verbosity};
use crate::cli::Logger;
use crate::http::ContextDir; use crate::http::ContextDir;
use crate::util::logger::Logger;
use base64::engine::general_purpose; use base64::engine::general_purpose;
use base64::Engine; use base64::Engine;
use curl::easy::{List, SslOpt}; use curl::easy::{List, SslOpt};

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
* *
*/ */
use crate::cli::Logger; use crate::util::logger::Logger;
/// Debug log text. /// Debug log text.
pub fn log_text(text: &str, logger: &Logger) { pub fn log_text(text: &str, logger: &Logger) {

View File

@ -16,8 +16,8 @@
* *
*/ */
use crate::cli::Logger;
use crate::http::{debug, mimetype, Request}; use crate::http::{debug, mimetype, Request};
use crate::util::logger::Logger;
impl Request { impl Request {
/// Log request body. /// Log request body.

View File

@ -16,8 +16,8 @@
* *
*/ */
use crate::cli::Logger;
use crate::http::{debug, mimetype, Response}; use crate::http::{debug, mimetype, Response};
use crate::util::logger::Logger;
impl Response { impl Response {
/// Log a response body as text if possible, or a slice of body bytes. /// Log a response body as text if possible, or a slice of body bytes.

View File

@ -24,14 +24,14 @@ use atty::Stream;
use clap::Command; use clap::Command;
use colored::*; use colored::*;
use hurl::cli::{CliError, CliOptions, Logger, OutputType}; use hurl::cli::{CliError, CliOptions, OutputType};
use hurl::http; use hurl::http;
use hurl::report; use hurl::report;
use hurl::report::html; use hurl::report::html;
use hurl::runner; use hurl::runner;
use hurl::runner::HurlResult; use hurl::runner::HurlResult;
use hurl::runner::RunnerOptions; use hurl::runner::RunnerOptions;
use hurl::util::logger::{BaseLogger, LoggerBuilder}; use hurl::util::logger::{BaseLogger, Logger, LoggerBuilder};
use hurl::{cli, output}; use hurl::{cli, output};
use hurl_core::ast::HurlFile; use hurl_core::ast::HurlFile;
use hurl_core::parser; use hurl_core::parser;

View File

@ -15,11 +15,12 @@
* limitations under the License. * limitations under the License.
* *
*/ */
use crate::cli::{CliError, Logger}; use crate::cli::CliError;
use crate::http::Response; use crate::http::Response;
use crate::output::write_output; use crate::output::write_output;
use crate::runner; use crate::runner;
use crate::runner::{HurlResult, RunnerError}; use crate::runner::{HurlResult, RunnerError};
use crate::util::logger::Logger;
use colored::Colorize; use colored::Colorize;
use hurl_core::ast::SourceInfo; use hurl_core::ast::SourceInfo;
use hurl_core::error::Error; use hurl_core::error::Error;

View File

@ -18,9 +18,9 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::time::Duration; use std::time::Duration;
use crate::cli::Logger;
use crate::http; use crate::http;
use crate::http::ClientOptions; use crate::http::ClientOptions;
use crate::util::logger::Logger;
use hurl_core::ast::*; use hurl_core::ast::*;
use super::core::*; use super::core::*;

View File

@ -19,18 +19,16 @@ use std::collections::HashMap;
use std::thread; use std::thread;
use std::time::Instant; use std::time::Instant;
use crate::cli::Logger;
use crate::http; use crate::http;
use crate::runner::entry::get_entry_verbosity; use crate::runner::core::*;
use crate::runner::entry;
use crate::runner::runner_options::RunnerOptions; use crate::runner::runner_options::RunnerOptions;
use crate::runner::Value; use crate::runner::Value;
use crate::util::logger::Logger;
use crate::util::logger::LoggerBuilder; use crate::util::logger::LoggerBuilder;
use hurl_core::ast::VersionValue::VersionAnyLegacy; use hurl_core::ast::VersionValue::VersionAnyLegacy;
use hurl_core::ast::*; use hurl_core::ast::*;
use super::core::*;
use super::entry;
/// Runs a `hurl_file`, issue from the given `filename`, with /// Runs a `hurl_file`, issue from the given `filename`, with
/// an `http_client`. Returns a [`HurlResult`] upon completion. /// an `http_client`. Returns a [`HurlResult`] upon completion.
/// ///
@ -42,13 +40,12 @@ use super::entry;
/// ``` /// ```
/// use std::collections::HashMap; /// use std::collections::HashMap;
/// use std::path::PathBuf; /// use std::path::PathBuf;
/// use hurl::cli::Logger;
/// use hurl_core::parser; /// use hurl_core::parser;
/// use hurl::http; /// use hurl::http;
/// use hurl::http::ContextDir; /// use hurl::http::ContextDir;
/// use hurl::runner; /// use hurl::runner;
/// use hurl::runner::{Value, RunnerOptionsBuilder, Verbosity}; /// use hurl::runner::{Value, RunnerOptionsBuilder, Verbosity};
/// use hurl::util::logger::LoggerBuilder; /// use hurl::util::logger::{Logger, LoggerBuilder};
/// ///
/// // Parse Hurl file /// // Parse Hurl file
/// let filename = "sample.hurl"; /// let filename = "sample.hurl";
@ -112,7 +109,7 @@ pub fn run(
// We compute these new overridden options for this entry, before entering into the `run` // We compute these new overridden options for this entry, before entering into the `run`
// function because entry options can modify the logger and we want the preamble // function because entry options can modify the logger and we want the preamble
// "Executing entry..." to be displayed based on the entry level verbosity. // "Executing entry..." to be displayed based on the entry level verbosity.
let entry_verbosity = get_entry_verbosity(entry, &runner_options.verbosity); let entry_verbosity = entry::get_entry_verbosity(entry, &runner_options.verbosity);
let mut builder = LoggerBuilder::new(); let mut builder = LoggerBuilder::new();
let logger = builder let logger = builder
.color(logger.color) .color(logger.color)

View File

@ -18,39 +18,11 @@
use std::collections::HashMap; use std::collections::HashMap;
use hurl::cli;
use hurl::http; use hurl::http;
use hurl::runner; use hurl::runner;
use hurl::runner::RunnerOptions; use hurl::runner::RunnerOptions;
use hurl::util::logger::LoggerBuilder; use hurl::util::logger::LoggerBuilder;
use hurl_core::ast::*; use hurl_core::ast::*;
use hurl_core::parser;
// Can be used for debugging
#[test]
fn test_hurl_file() {
let filename = "../../integration/tests_ok/bom.hurl";
let content = cli::read_to_string(filename).expect("Something went wrong reading the file");
let hurl_file = parser::parse_hurl_file(content.as_str()).unwrap();
let variables = HashMap::new();
let mut client = http::Client::new(None);
let mut builder = LoggerBuilder::new();
let logger = builder
.filename(filename)
.content(&content)
.build()
.unwrap();
let runner_options = RunnerOptions::default();
let _hurl_log = runner::run(
&hurl_file,
filename,
&mut client,
&runner_options,
&variables,
&logger,
);
}
#[cfg(test)] #[cfg(test)]
fn hello_request() -> Request { fn hello_request() -> Request {