Skip to content

Commit

Permalink
Remove external logs (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
danimhr authored Dec 6, 2024
1 parent 0213f8c commit f0e09c3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions auction-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use {
io::IsTerminal,
time::Duration,
},
tracing::Metadata,
tracing_subscriber::{
filter::{
self,
Expand All @@ -40,6 +41,10 @@ mod server;
mod state;
mod subwallet;

fn is_internal(metadata: &Metadata) -> bool {
metadata.target().starts_with("auction_server")
}

#[tokio::main]
async fn main() -> Result<()> {
// Initialize a Tracing Subscriber
Expand Down Expand Up @@ -71,7 +76,7 @@ async fn main() -> Result<()> {
let registry = tracing_subscriber::registry()
.with(MetricsLayer.with_filter(filter::filter_fn(is_metrics)))
.with(telemetry.with_filter(filter::filter_fn(|metadata| {
!is_metrics(metadata) && metadata.target().starts_with("auction_server")
!is_metrics(metadata) && is_internal(metadata)
})));

if std::io::stderr().is_terminal() {
Expand All @@ -80,7 +85,9 @@ async fn main() -> Result<()> {
log_layer
.compact()
.with_filter(LevelFilter::INFO)
.with_filter(filter::filter_fn(|metadata| !is_metrics(metadata))),
.with_filter(filter::filter_fn(|metadata| {
!is_metrics(metadata) && is_internal(metadata)
})),
)
.init();
} else {
Expand All @@ -89,7 +96,9 @@ async fn main() -> Result<()> {
log_layer
.json()
.with_filter(LevelFilter::INFO)
.with_filter(filter::filter_fn(|metadata| !is_metrics(metadata))),
.with_filter(filter::filter_fn(|metadata| {
!is_metrics(metadata) && is_internal(metadata)
})),
)
.init();
}
Expand Down
2 changes: 1 addition & 1 deletion auction-server/src/opportunity/service/get_spoof_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Service<ChainTypeEvm> {
let result = find_spoof_info(input.token, Arc::new(config.provider.clone()))
.await
.unwrap_or_else(|e| {
tracing::error!("Error finding spoof info: {:?}", e);
tracing::warn!(error = ?e, "Couldn't find spoof info");
entities::SpoofInfo {
token: input.token,
state: entities::SpoofState::UnableToSpoof,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ impl Service<ChainTypeEvm> {
{
Ok(bid) => Ok(bid.id),
Err(e) => {
tracing::error!(
tracing::warn!(
error = ?e,
opportunity = ?opportunity,
bid_create = ?bid_create,
"Error handling bid",
"Handling bid failed for opportunity_bid",
);
match e {
RestError::SimulationError { result, reason } => {
Expand Down

0 comments on commit f0e09c3

Please sign in to comment.