Skip to content

Commit

Permalink
wip: rename traceable to trace
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed May 17, 2024
1 parent cf80426 commit c77d2c4
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion contrib/dyn_templates/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rocket::fairing::Fairing;
use rocket::response::{self, Responder};
use rocket::http::{ContentType, Status};
use rocket::figment::{value::Value, error::Error};
use rocket::trace::Traceable;
use rocket::trace::Trace;
use rocket::serde::Serialize;

use crate::Engines;
Expand Down
2 changes: 1 addition & 1 deletion contrib/sync_db_pools/lib/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rocket::fairing::{AdHoc, Fairing};
use rocket::request::{Request, Outcome, FromRequest};
use rocket::outcome::IntoOutcome;
use rocket::http::Status;
use rocket::trace::Traceable;
use rocket::trace::Trace;

use rocket::tokio::time::timeout;
use rocket::tokio::sync::{OwnedSemaphorePermit, Semaphore, Mutex};
Expand Down
2 changes: 1 addition & 1 deletion core/lib/src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::config::{ShutdownConfig, Ident, CliColors};
use crate::request::{self, Request, FromRequest};
use crate::http::uncased::Uncased;
use crate::data::Limits;
use crate::trace::{Traceable, TraceFormat};
use crate::trace::{Trace, TraceFormat};

/// Rocket server configuration.
///
Expand Down
2 changes: 1 addition & 1 deletion core/lib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::sync::Arc;
use figment::Profile;

use crate::listener::Endpoint;
use crate::trace::Traceable;
use crate::trace::Trace;
use crate::{Ignite, Orbit, Phase, Rocket};

/// An error that occurs during launch.
Expand Down
2 changes: 1 addition & 1 deletion core/lib/src/lifecycle.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use futures::future::{FutureExt, Future};

use crate::{route, catcher, Rocket, Orbit, Request, Response, Data};
use crate::trace::Traceable;
use crate::trace::Trace;
use crate::util::Formatter;
use crate::data::IoHandler;
use crate::http::{Method, Status, Header};
Expand Down
4 changes: 2 additions & 2 deletions core/lib/src/rocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use figment::{Figment, Provider};
use futures::TryFutureExt;

use crate::shutdown::{Stages, Shutdown};
use crate::trace::{Traceable, TraceableCollection};
use crate::trace::{Trace, TraceAll};
use crate::{sentinel, shield::Shield, Catcher, Config, Route};
use crate::listener::{Bind, DefaultListener, Endpoint, Listener};
use crate::router::Router;
Expand Down Expand Up @@ -247,7 +247,7 @@ impl Rocket<Build> {
B::Error: fmt::Display,
M: Fn(&Origin<'a>, T) -> T,
F: Fn(&mut Self, T),
T: Clone + Traceable,
T: Clone + Trace,
{
let mut base = match base.clone().try_into() {
Ok(origin) => origin.into_owned(),
Expand Down
2 changes: 1 addition & 1 deletion core/lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::error::log_server_error;
use crate::data::{IoStream, RawStream};
use crate::util::{spawn_inspect, FutureExt, ReaderStream};
use crate::http::Status;
use crate::trace::{Traceable, TraceableCollection};
use crate::trace::{Trace, TraceAll};

type Result<T, E = crate::Error> = std::result::Result<T, E>;

Expand Down
2 changes: 1 addition & 1 deletion core/lib/src/trace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub mod subscriber;
pub(crate) mod level;

#[doc(inline)]
pub use traceable::{Traceable, TraceableCollection};
pub use traceable::{Trace, TraceAll};

#[doc(inline)]
pub use macros::*;
Expand Down
40 changes: 20 additions & 20 deletions core/lib/src/trace/traceable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use figment::Figment;
use rocket::http::Header;
use tracing::Level;

pub trait Traceable {
pub trait Trace {
fn trace(&self, level: Level);

#[inline(always)] fn trace_info(&self) { self.trace(Level::INFO) }
Expand All @@ -20,7 +20,7 @@ pub trait Traceable {
#[inline(always)] fn trace_trace(&self) { self.trace(Level::TRACE) }
}

pub trait TraceableCollection: Sized {
pub trait TraceAll: Sized {
fn trace_all(self, level: Level);

#[inline(always)] fn trace_all_info(self) { self.trace_all(Level::INFO) }
Expand All @@ -30,20 +30,20 @@ pub trait TraceableCollection: Sized {
#[inline(always)] fn trace_all_trace(self) { self.trace_all(Level::TRACE) }
}

impl<T: Traceable, I: IntoIterator<Item = T>> TraceableCollection for I {
impl<T: Trace, I: IntoIterator<Item = T>> TraceAll for I {
fn trace_all(self, level: Level) {
self.into_iter().for_each(|i| i.trace(level))
}
}

impl<T: Traceable> Traceable for &T {
impl<T: Trace> Trace for &T {
#[inline(always)]
fn trace(&self, level: Level) {
T::trace(self, level)
}
}

impl Traceable for Figment {
impl Trace for Figment {
fn trace(&self, level: Level) {
for param in Config::PARAMETERS {
if let Some(source) = self.find_metadata(param) {
Expand All @@ -70,7 +70,7 @@ impl Traceable for Figment {
}
}

impl Traceable for Config {
impl Trace for Config {
fn trace(&self, level: Level) {
event! { level, "config",
http2 = cfg!(feature = "http2"),
Expand Down Expand Up @@ -132,7 +132,7 @@ impl Traceable for Config {
}
}

impl Traceable for Route {
impl Trace for Route {
fn trace(&self, level: Level) {
event! { level, "route",
name = self.name.as_ref().map(|n| &**n),
Expand All @@ -155,7 +155,7 @@ impl Traceable for Route {
}
}

impl Traceable for Catcher {
impl Trace for Catcher {
fn trace(&self, level: Level) {
event! { level, "catcher",
name = self.name.as_ref().map(|n| &**n),
Expand All @@ -169,19 +169,19 @@ impl Traceable for Catcher {
}
}

impl Traceable for &dyn crate::fairing::Fairing {
impl Trace for &dyn crate::fairing::Fairing {
fn trace(&self, level: Level) {
self.info().trace(level)
}
}

impl Traceable for crate::fairing::Info {
impl Trace for crate::fairing::Info {
fn trace(&self, level: Level) {
event!(level, "fairing", name = self.name, kind = %self.kind)
}
}

impl Traceable for figment::error::Kind {
impl Trace for figment::error::Kind {
fn trace(&self, _: Level) {
use figment::error::{OneOf as V, Kind::*};

Expand All @@ -202,7 +202,7 @@ impl Traceable for figment::error::Kind {
}
}

impl Traceable for figment::Error {
impl Trace for figment::Error {
fn trace(&self, _: Level) {
for e in self.clone() {
let span = tracing::error_span! {
Expand All @@ -220,13 +220,13 @@ impl Traceable for figment::Error {
}
}

impl Traceable for Header<'_> {
impl Trace for Header<'_> {
fn trace(&self, level: Level) {
event!(level, "header", name = self.name().as_str(), value = self.value());
}
}

impl Traceable for route::Outcome<'_> {
impl Trace for route::Outcome<'_> {
fn trace(&self, level: Level) {
event!(level, "outcome",
outcome = match self {
Expand All @@ -243,19 +243,19 @@ impl Traceable for route::Outcome<'_> {
}
}

impl Traceable for Response<'_> {
impl Trace for Response<'_> {
fn trace(&self, level: Level) {
event!(level, "response", status = self.status().code);
}
}

impl Traceable for Error {
impl Trace for Error {
fn trace(&self, level: Level) {
self.kind.trace(level);
}
}

impl Traceable for Sentry {
impl Trace for Sentry {
fn trace(&self, level: Level) {
let (file, line, col) = self.location;
event!(level, "sentry",
Expand All @@ -265,13 +265,13 @@ impl Traceable for Sentry {
}
}

impl Traceable for Request<'_> {
impl Trace for Request<'_> {
fn trace(&self, level: Level) {
event!(level, "request", method = %self.method(), uri = %self.uri())
}
}

impl Traceable for ConnectionMeta {
impl Trace for ConnectionMeta {
fn trace(&self, level: Level) {
event!(level, "connection",
endpoint = self.peer_endpoint.as_ref().map(display),
Expand All @@ -280,7 +280,7 @@ impl Traceable for ConnectionMeta {
}
}

impl Traceable for ErrorKind {
impl Trace for ErrorKind {
fn trace(&self, level: Level) {
use ErrorKind::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/fairings/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::Arc;

use rocket::{Rocket, Request, State, Data, Build};
use rocket::fairing::{self, AdHoc, Fairing, Info, Kind};
use rocket::trace::Traceable;
use rocket::trace::Trace;
use rocket::http::Method;

struct Token(i64);
Expand Down
2 changes: 1 addition & 1 deletion examples/tls/src/redirector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rocket::{route, Error, Request, Data, Route, Orbit, Rocket, Ignite};
use rocket::fairing::{Fairing, Info, Kind};
use rocket::response::Redirect;
use rocket::listener::tcp::TcpListener;
use rocket::trace::Traceable;
use rocket::trace::Trace;

#[derive(Debug, Clone, Copy, Default)]
pub struct Redirector(u16);
Expand Down
2 changes: 1 addition & 1 deletion testbench/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rocket::fairing::AdHoc;
use rocket::listener::{Bind, DefaultListener};
use rocket::serde::{Deserialize, DeserializeOwned, Serialize};
use rocket::{Build, Ignite, Rocket};
use rocket::trace::Traceable;
use rocket::trace::Trace;

use ipc_channel::ipc::{IpcOneShotServer, IpcReceiver, IpcSender};

Expand Down

0 comments on commit c77d2c4

Please sign in to comment.