diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2021-02-14 00:31:14 -0500 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2021-02-14 00:31:14 -0500 |
commit | 548304fd69614479790c36ddb0615599df0130b2 (patch) | |
tree | db0534ba6575e9ad897f6554ff41cddfdcc4ca7c | |
parent | 5fe7c4f8bae147db49aaa275fe540b2b4667b3a1 (diff) |
add tracing
-rw-r--r-- | ipfs-api/Cargo.toml | 2 | ||||
-rw-r--r-- | ipfs-api/examples/add_file.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/add_tar.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/bootstrap_default.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/config.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/dag.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/dns.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/get_commands.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/get_stats.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/get_swarm.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/get_version.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/log_tail.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/mfs.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/ping_peer.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/pubsub.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/replace_config.rs | 2 | ||||
-rw-r--r-- | ipfs-api/examples/resolve_name.rs | 2 | ||||
-rw-r--r-- | ipfs-api/src/client/internal.rs | 3 | ||||
-rw-r--r-- | ipfs-api/src/read.rs | 6 |
19 files changed, 43 insertions, 0 deletions
diff --git a/ipfs-api/Cargo.toml b/ipfs-api/Cargo.toml index b165c11..3902235 100644 --- a/ipfs-api/Cargo.toml +++ b/ipfs-api/Cargo.toml @@ -43,6 +43,7 @@ serde_json = "1.0" serde_urlencoded = "0.7" tokio = "1.2" tokio-util = { version = "0.6", features = ["codec"] } +tracing = "0.1" walkdir = "2.3" dirs = "3.0" parity-multiaddr = "0.11" @@ -57,3 +58,4 @@ hyper-tls = "0.5" tar = "0.4" tokio = { version = "1.2", features = ["rt-multi-thread", "macros", "time"] } tokio-stream = { version = "0.1", features = ["time"] } +tracing-subscriber = { version = "0.2", features = ["fmt"] } diff --git a/ipfs-api/examples/add_file.rs b/ipfs-api/examples/add_file.rs index 5917884..a19e4a2 100644 --- a/ipfs-api/examples/add_file.rs +++ b/ipfs-api/examples/add_file.rs @@ -14,6 +14,8 @@ use std::fs::File; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("note: this must be run in the root of the project repository"); eprintln!("connecting to localhost:5001..."); diff --git a/ipfs-api/examples/add_tar.rs b/ipfs-api/examples/add_tar.rs index a89c805..e20cb1e 100644 --- a/ipfs-api/examples/add_tar.rs +++ b/ipfs-api/examples/add_tar.rs @@ -16,6 +16,8 @@ use tar::Builder; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("note: this must be run in the root of the project repository"); eprintln!("connecting to localhost:5001..."); diff --git a/ipfs-api/examples/bootstrap_default.rs b/ipfs-api/examples/bootstrap_default.rs index 8dc3772..f693341 100644 --- a/ipfs-api/examples/bootstrap_default.rs +++ b/ipfs-api/examples/bootstrap_default.rs @@ -14,6 +14,8 @@ use ipfs_api::IpfsClient; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("connecting to localhost:5001..."); let client = IpfsClient::default(); diff --git a/ipfs-api/examples/config.rs b/ipfs-api/examples/config.rs index 3964146..1e0a3c3 100644 --- a/ipfs-api/examples/config.rs +++ b/ipfs-api/examples/config.rs @@ -13,6 +13,8 @@ use ipfs_api::IpfsClient; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("note: this must be run in the root of the project repository"); eprintln!("connecting to localhost:5001..."); diff --git a/ipfs-api/examples/dag.rs b/ipfs-api/examples/dag.rs index 20d7bef..5632021 100644 --- a/ipfs-api/examples/dag.rs +++ b/ipfs-api/examples/dag.rs @@ -15,6 +15,8 @@ use std::io::Cursor; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("note: this must be run in the root of the project repository"); eprintln!("connecting to localhost:5001..."); diff --git a/ipfs-api/examples/dns.rs b/ipfs-api/examples/dns.rs index a9b0604..4a262c9 100644 --- a/ipfs-api/examples/dns.rs +++ b/ipfs-api/examples/dns.rs @@ -13,6 +13,8 @@ use ipfs_api::IpfsClient; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("connecting to localhost:5001..."); let client = IpfsClient::default(); diff --git a/ipfs-api/examples/get_commands.rs b/ipfs-api/examples/get_commands.rs index 5ca7b00..fb019b6 100644 --- a/ipfs-api/examples/get_commands.rs +++ b/ipfs-api/examples/get_commands.rs @@ -35,6 +35,8 @@ fn print_recursive(indent: usize, cmd: &response::CommandsResponse) { #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("connecting to localhost:5001..."); let client = IpfsClient::default(); diff --git a/ipfs-api/examples/get_stats.rs b/ipfs-api/examples/get_stats.rs index c2b6835..f51a9da 100644 --- a/ipfs-api/examples/get_stats.rs +++ b/ipfs-api/examples/get_stats.rs @@ -13,6 +13,8 @@ use ipfs_api::IpfsClient; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("connecting to localhost:5001..."); let client = IpfsClient::default(); diff --git a/ipfs-api/examples/get_swarm.rs b/ipfs-api/examples/get_swarm.rs index 114f70e..9f30b12 100644 --- a/ipfs-api/examples/get_swarm.rs +++ b/ipfs-api/examples/get_swarm.rs @@ -14,6 +14,8 @@ use ipfs_api::IpfsClient; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("connecting to localhost:5001..."); let client = IpfsClient::default(); diff --git a/ipfs-api/examples/get_version.rs b/ipfs-api/examples/get_version.rs index bc91f50..83c3f90 100644 --- a/ipfs-api/examples/get_version.rs +++ b/ipfs-api/examples/get_version.rs @@ -13,6 +13,8 @@ use ipfs_api::IpfsClient; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("connecting to localhost:5001..."); let client = IpfsClient::default(); diff --git a/ipfs-api/examples/log_tail.rs b/ipfs-api/examples/log_tail.rs index 2e4955a..e590a61 100644 --- a/ipfs-api/examples/log_tail.rs +++ b/ipfs-api/examples/log_tail.rs @@ -14,6 +14,8 @@ use ipfs_api::IpfsClient; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("connecting to localhost:5001..."); let client = IpfsClient::default(); diff --git a/ipfs-api/examples/mfs.rs b/ipfs-api/examples/mfs.rs index 85dd0f7..836e238 100644 --- a/ipfs-api/examples/mfs.rs +++ b/ipfs-api/examples/mfs.rs @@ -23,6 +23,8 @@ fn print_stat(stat: response::FilesStatResponse) { #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("note: this must be run in the root of the project repository"); eprintln!("connecting to localhost:5001..."); diff --git a/ipfs-api/examples/ping_peer.rs b/ipfs-api/examples/ping_peer.rs index 08b0496..eddc3ba 100644 --- a/ipfs-api/examples/ping_peer.rs +++ b/ipfs-api/examples/ping_peer.rs @@ -15,6 +15,8 @@ use ipfs_api::{response::PingResponse, IpfsClient}; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("connecting to localhost:5001..."); let client = IpfsClient::default(); diff --git a/ipfs-api/examples/pubsub.rs b/ipfs-api/examples/pubsub.rs index baa1b1b..1c6a34c 100644 --- a/ipfs-api/examples/pubsub.rs +++ b/ipfs-api/examples/pubsub.rs @@ -29,6 +29,8 @@ fn get_client() -> IpfsClient { #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("note: ipfs must be run with the --enable-pubsub-experiment flag"); let publish_client = get_client(); diff --git a/ipfs-api/examples/replace_config.rs b/ipfs-api/examples/replace_config.rs index 372609b..0647b38 100644 --- a/ipfs-api/examples/replace_config.rs +++ b/ipfs-api/examples/replace_config.rs @@ -14,6 +14,8 @@ use std::io::Cursor; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("note: this must be run in the root of the project repository"); eprintln!("connecting to localhost:5001..."); diff --git a/ipfs-api/examples/resolve_name.rs b/ipfs-api/examples/resolve_name.rs index 57ad10e..a419511 100644 --- a/ipfs-api/examples/resolve_name.rs +++ b/ipfs-api/examples/resolve_name.rs @@ -16,6 +16,8 @@ const IPFS_IPNS: &str = "/ipns/ipfs.io"; #[cfg_attr(feature = "with-actix", actix_rt::main)] #[cfg_attr(feature = "with-hyper", tokio::main)] async fn main() { + tracing_subscriber::fmt::init(); + eprintln!("connecting to localhost:5001..."); let client = IpfsClient::default(); diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs index 94bd490..eb48857 100644 --- a/ipfs-api/src/client/internal.rs +++ b/ipfs-api/src/client/internal.rs @@ -31,6 +31,7 @@ use std::{ path::{Path, PathBuf}, }; use tokio_util::codec::{Decoder, FramedRead}; +use tracing::{event, Level}; const FILE_DESCRIPTOR_LIMIT: usize = 127; @@ -99,6 +100,8 @@ impl IpfsClient { ::serde_urlencoded::to_string(req)? ); + event!(Level::INFO, url = ?url); + #[cfg(feature = "with-hyper")] { url.parse::<Uri>().map_err(From::from).and_then(move |url| { diff --git a/ipfs-api/src/read.rs b/ipfs-api/src/read.rs index bf19157..d17e396 100644 --- a/ipfs-api/src/read.rs +++ b/ipfs-api/src/read.rs @@ -16,6 +16,7 @@ use serde::Deserialize; use std::{cmp, fmt::Display, io, marker::PhantomData, pin::Pin}; use tokio::io::{AsyncRead, ReadBuf}; use tokio_util::codec::Decoder; +use tracing::{event, instrument, Level}; /// A decoder for a response where each line is a full json object. /// @@ -49,10 +50,13 @@ where /// Tries to find a new line character. If it does, it will split the buffer, /// and parse the first slice. /// + #[instrument(skip(self, src), fields(stream_trailer = self.parse_stream_error))] fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> { let nl_index = src.iter().position(|b| *b == b'\n'); if let Some(pos) = nl_index { + event!(Level::INFO, "Found new line delimeter in buffer"); + let slice = src.split_to(pos + 1); let slice = &slice[..slice.len() - 1]; @@ -81,6 +85,8 @@ where } } } else { + event!(Level::INFO, "Waiting for more data to decode JSON"); + Ok(None) } } |