From f5228c52b0880204c68e00f2997cd3d87acfeb4e Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Thu, 5 Sep 2024 10:14:50 +1000 Subject: [PATCH] chore: Use the inmem logging functions in the FFI crate --- rust/pact_ffi/src/log/ffi.rs | 3 +-- rust/pact_ffi/src/log/inmem_buffer.rs | 2 +- rust/pact_ffi/src/log/mod.rs | 4 ++++ rust/pact_ffi/src/mock_server/mod.rs | 2 +- rust/pact_ffi/src/verifier/mod.rs | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/rust/pact_ffi/src/log/ffi.rs b/rust/pact_ffi/src/log/ffi.rs index 3bd3bbfe2..5f1bb40a3 100644 --- a/rust/pact_ffi/src/log/ffi.rs +++ b/rust/pact_ffi/src/log/ffi.rs @@ -8,9 +8,8 @@ use std::str::from_utf8; use libc::{c_char, c_int}; use log::{error, LevelFilter as LogLevelFilter}; -use pact_matching::logging::fetch_buffer_contents; - use crate::error::set_error_msg; +use crate::log::inmem_buffer::fetch_buffer_contents; use crate::log::level_filter::LevelFilter; use crate::log::logger::{add_sink, apply_logger, init_logger}; use crate::log::sink::Sink; diff --git a/rust/pact_ffi/src/log/inmem_buffer.rs b/rust/pact_ffi/src/log/inmem_buffer.rs index 07e12bd66..4df8ab0cb 100644 --- a/rust/pact_ffi/src/log/inmem_buffer.rs +++ b/rust/pact_ffi/src/log/inmem_buffer.rs @@ -17,7 +17,7 @@ pub(crate) struct InMemBuffer { } impl Write for InMemBuffer { fn write(&mut self, buf: &[u8]) -> io::Result { - pact_matching::logging::write_to_log_buffer(buf); + write_to_log_buffer(buf); Ok(buf.len()) } diff --git a/rust/pact_ffi/src/log/mod.rs b/rust/pact_ffi/src/log/mod.rs index b61b19983..b5df13c5b 100644 --- a/rust/pact_ffi/src/log/mod.rs +++ b/rust/pact_ffi/src/log/mod.rs @@ -17,3 +17,7 @@ pub use crate::log::ffi::{ pactffi_log_to_file, pactffi_log_to_buffer }; +pub use crate::log::inmem_buffer::{ + fetch_buffer_contents, + write_to_log_buffer +}; diff --git a/rust/pact_ffi/src/mock_server/mod.rs b/rust/pact_ffi/src/mock_server/mod.rs index 5377bb1be..2fd59b57f 100644 --- a/rust/pact_ffi/src/mock_server/mod.rs +++ b/rust/pact_ffi/src/mock_server/mod.rs @@ -63,7 +63,6 @@ use tokio_rustls::rustls::ServerConfig; use tracing::{error, warn}; use uuid::Uuid; -use pact_matching::logging::fetch_buffer_contents; use pact_matching::metrics::{MetricEvent, send_metrics}; use pact_mock_server::{MANAGER, mock_server_mismatches, MockServerError, tls::TlsConfigBuilder, WritePactFileErr}; use pact_mock_server::mock_server::MockServerConfig; @@ -72,6 +71,7 @@ use pact_models::generators::GeneratorCategory; use pact_models::matchingrules::{Category, MatchingRuleCategory}; use crate::{convert_cstr, ffi_fn, safe_str}; +use crate::log::fetch_buffer_contents; use crate::mock_server::handles::{PactHandle, path_from_dir}; use crate::string::optional_str; diff --git a/rust/pact_ffi/src/verifier/mod.rs b/rust/pact_ffi/src/verifier/mod.rs index dd2834e87..38ed1fa87 100644 --- a/rust/pact_ffi/src/verifier/mod.rs +++ b/rust/pact_ffi/src/verifier/mod.rs @@ -16,10 +16,10 @@ use pact_models::prelude::HttpAuth; use regex::Regex; use serde::{Deserialize, Serialize}; -use pact_matching::logging::fetch_buffer_contents; use pact_verifier::selectors::{consumer_tags_to_selectors, json_to_selectors}; use crate::{as_mut, as_ref, ffi_fn, RUNTIME, safe_str}; +use crate::log::fetch_buffer_contents; use crate::ptr; use crate::util::string::{if_null, optional_str};