-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove
log.log_http_headers
config and move log calls into submodul…
…es (#1309) This rather ad-hoc random config option was weird. Now two noisy log messages can be individually filtered by moving them to separate submodules. This changes the default when just setting `filters.tobira = "trace`" in that now, HTTP headers are also printed. But I think that's totally fine. Fixes #1291
- Loading branch information
Showing
6 changed files
with
47 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//! This module contains a bunch of small inline modules to make it possible to | ||
//! easily filter out individual log messages with out filter system. | ||
|
||
use hyper::{body::Incoming, Request}; | ||
use crate::prelude::*; | ||
|
||
pub mod req { | ||
use super::*; | ||
|
||
pub fn log(req: &Request<Incoming>) { | ||
trace!( | ||
method = ?req.method(), | ||
path = req.uri().path_and_query().map_or("", |pq| pq.as_str()), | ||
"Incoming HTTP request", | ||
); | ||
} | ||
} | ||
|
||
|
||
|
||
pub mod headers { | ||
use super::*; | ||
|
||
pub fn log(req: &Request<Incoming>) { | ||
if tracing::enabled!(tracing::Level::TRACE) { | ||
let mut out = String::new(); | ||
for (name, value) in req.headers() { | ||
use std::fmt::Write; | ||
write!(out, "\n {}: {}", name, String::from_utf8_lossy(value.as_bytes())).unwrap(); | ||
} | ||
trace!("HTTP Headers: {}", out); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ use self::{ | |
|
||
mod assets; | ||
mod handlers; | ||
mod log; | ||
pub(crate) mod response; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters