From 5a0cdd271ffeee7a7e5095b49f003d899fcc582f Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Sat, 22 Jul 2023 01:34:41 -0400 Subject: [PATCH] Only print logs from the registry, add some debug info to pulling blobs --- src/api/blobs.rs | 4 ++++ src/config.rs | 2 ++ src/main.rs | 20 +++++++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/api/blobs.rs b/src/api/blobs.rs index 8dc78ce..39c30b1 100644 --- a/src/api/blobs.rs +++ b/src/api/blobs.rs @@ -56,6 +56,8 @@ pub async fn pull_digest_get(Path((_name, layer_digest)): Path<(String, String)> // convert the `Stream` into an `axum::body::HttpBody` let body = StreamBody::new(stream); + debug!("length of range request: {}", starting - ending); + Ok(( StatusCode::OK, [ @@ -71,6 +73,8 @@ pub async fn pull_digest_get(Path((_name, layer_digest)): Path<(String, String)> // convert the `Stream` into an `axum::body::HttpBody` let body = StreamBody::new(stream); + debug!("length of streamed request: {}", len); + Ok(( StatusCode::OK, [ diff --git a/src/config.rs b/src/config.rs index 549a8a8..e306bbc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -64,6 +64,8 @@ pub struct Config { pub listen_address: String, pub listen_port: String, url: Option, + #[serde(default)] + pub extra_logging: bool, #[serde(deserialize_with = "serialize_log_level", default = "default_log_level")] pub log_level: Level, pub ldap: Option, diff --git a/src/main.rs b/src/main.rs index 73efc2e..437822c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,8 @@ use tracing::{debug, info}; use app_state::AppState; use database::Database; +use tracing_subscriber::filter; +use tracing_subscriber::{filter::FilterFn, layer::{Layer as TracingLayer, SubscriberExt}, util::SubscriberInitExt,}; use crate::storage::StorageDriver; use crate::storage::filesystem::FilesystemDriver; @@ -72,9 +74,21 @@ async fn main() -> anyhow::Result<()> { let mut config = Config::new() .expect("Failure to parse config!"); - tracing_subscriber::fmt() - .with_max_level(config.log_level) - .init(); + // Create a tracing subscriber + if !config.extra_logging { + // only allow logs from the registry + tracing_subscriber::registry() + .with(tracing_subscriber::fmt::layer()) + .with(filter::Targets::new() + .with_target("orca_registry", config.log_level) + ) + .init(); + } else { + // allow all logs from any crates + tracing_subscriber::fmt() + .with_max_level(config.log_level) + .init(); + } let sqlite_config = match &config.database { DatabaseConfig::Sqlite(sqlite) => sqlite,