Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ doctest = false
name = "stub_gen"
path = "src/stub_gen.rs"

[features]
logging = ["dep:pyo3-log", "dep:log"]

[dependencies]
tokio = { version = "1.44.0", features = ["sync"] }
tokio = { version = "1.44.1", features = ["sync"] }
pyo3 = { version = "0.24.0", features = [
"indexmap",
"multiple-pymethods",
"generate-import-lib",
] }
pyo3-async-runtimes = { version = "0.24.0", features = ["tokio-runtime", "unstable-streams"] }
pyo3-log = { version = "0.12.1", optional = true }
pyo3-stub-gen = "0.7.0"
log = { version = "0.4", optional = true }
serde = { version = "1.0.219", features = ["derive"] }
Expand Down
2 changes: 0 additions & 2 deletions src/async_impl/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ impl Response {
/// Closes the response connection.
pub fn close(&self, py: Python) -> PyResult<()> {
py.allow_threads(|| {
#[cfg(feature = "logging")]
log::debug!("Closing HTTP connection");
let _ = self.inner().map(drop);
Ok(())
})
Expand Down
6 changes: 0 additions & 6 deletions src/async_impl/ws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ impl WebSocket {
code: Option<u16>,
reason: Option<String>,
) -> PyResult<()> {
#[cfg(feature = "logging")]
log::debug!("Closing WebSocket connection");

let mut lock = receiver.lock().await;
let receiver = lock.take();
drop(lock);
Expand All @@ -115,9 +112,6 @@ impl WebSocket {
.map_err(wrap_rquest_error)?;
sender.flush().await.map_err(wrap_rquest_error)?;
sender.close().await.map_err(wrap_rquest_error)?;

#[cfg(feature = "logging")]
log::debug!("WebSocket connection closed");
}

Ok(())
Expand Down
9 changes: 1 addition & 8 deletions src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,7 @@ fn init(
HickoryDnsResolver::new(strategy.into_ffi())
.map(Arc::new)
.map_err(|err| {
#[cfg(feature = "logging")]
{
log::error!("failed to initialize the DNS resolver: {}", err);
}
#[cfg(not(feature = "logging"))]
{
eprintln!("failed to initialize the DNS resolver: {}", err);
}
eprintln!("failed to initialize the DNS resolver: {}", err);
"failed to initialize the DNS resolver"
})
})
Expand Down
16 changes: 0 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ mod typing;

use async_impl::{Client, Message, Response, Streamer, WebSocket};
use blocking::{BlockingClient, BlockingResponse, BlockingStreamer, BlockingWebSocket};
#[cfg(feature = "logging")]
use log::LevelFilter;
use param::{RequestParams, WebSocketParams};
use pyo3::{prelude::*, pybacked::PyBackedStr};
use pyo3_async_runtimes::tokio::future_into_py;
#[cfg(feature = "logging")]
use pyo3_log::{Caching, Logger};
use pyo3_stub_gen::{define_stub_info_gatherer, derive::*};
use typing::{
Impersonate, ImpersonateOS, LookupIpStrategy, Method, Multipart, Part, Proxy, SocketAddr,
Expand Down Expand Up @@ -323,18 +319,6 @@ fn websocket(
fn rnet(m: &Bound<'_, PyModule>) -> PyResult<()> {
pyo3::prepare_freethreaded_python();

// A good place to install the Rust -> Python logger.
#[cfg(feature = "logging")]
{
let handle = Logger::new(m.py(), Caching::LoggersAndLevels)?
.filter(LevelFilter::Trace)
.install()
.expect("Someone installed a logger before rnet.");

// Some time in the future when logging changes, reset the caches:
handle.reset();
}

m.add_class::<Method>()?;
m.add_class::<Version>()?;
m.add_class::<Impersonate>()?;
Expand Down