Change HTTP Log to debug, unless KRILL_HTTP_LOG_INFO is set. (#513)

This commit is contained in:
Tim Bruijnzeels
2021-05-12 11:26:23 +02:00
parent 73e25d7f5b
commit c23dfdd8c3
2 changed files with 9 additions and 4 deletions
+1
View File
@@ -21,6 +21,7 @@ pub const KRILL_ENV_LOG_LEVEL: &str = "KRILL_LOG_LEVEL";
pub const KRILL_ENV_ADMIN_TOKEN: &str = "KRILL_ADMIN_TOKEN";
pub const KRILL_ENV_ADMIN_TOKEN_DEPRECATED: &str = "KRILL_AUTH_TOKEN";
pub const KRILL_ENV_SERVER_PORT: &str = "KRILL_SERVER_PORT";
pub const KRILL_ENV_HTTP_LOG_INFO: &str = "KRILL_HTTP_LOG_INFO";
pub fn enable_test_mode() {
std::env::set_var(KRILL_ENV_TEST, "1");
+8 -4
View File
@@ -21,10 +21,10 @@ use hyper::server::conn::AddrIncoming;
use hyper::service::{make_service_fn, service_fn};
use hyper::Method;
use crate::commons::api::{
use crate::{commons::api::{
BgpStats, ChildHandle, CommandHistoryCriteria, Handle, ParentCaContact, ParentHandle, PublisherList,
RoaDefinitionUpdates, RtaName, Token,
};
}, constants::KRILL_ENV_HTTP_LOG_INFO};
use crate::commons::api::{ParentCaReq, RepositoryContact};
use crate::commons::bgp::BgpAnalysisAdvice;
use crate::commons::error::Error;
@@ -176,8 +176,12 @@ impl RequestLogger {
_ => {}
}
info!("{} {} {}", self.req_method, self.req_path, response.status());
if env::var(KRILL_ENV_HTTP_LOG_INFO).is_ok() {
info!("{} {} {}", self.req_method, self.req_path, response.status());
} else {
debug!("{} {} {}", self.req_method, self.req_path, response.status());
}
if response.loggable() && log_enabled!(log::Level::Trace) {
trace!("Response: headers={:?} body={:?}", response.headers(), response.body());
}