Skip to content

Commit

Permalink
refactor: optimize logger and error result of amp-syncer
Browse files Browse the repository at this point in the history
wangeguo committed Feb 24, 2024
1 parent fe89b2c commit 571ff14
Showing 4 changed files with 12 additions and 13 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.8.18"
version = "0.8.19"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/amphitheatre-app/amphitheatre"
3 changes: 1 addition & 2 deletions syncer/src/handle.rs
Original file line number Diff line number Diff line change
@@ -15,11 +15,10 @@
use std::path::Path;

use amp_common::sync::{self, Synchronization};
use std::io::Result;
use tar::Archive;
use tracing::{debug, error, info, warn};

type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

/// Overwrite workspace's files with payload tarball.
pub fn overwrite(workspace: &Path, req: &Synchronization) -> Result<()> {
debug!("Received overwrite event, workspace: {:?}, req: {:?}", workspace, req);
4 changes: 2 additions & 2 deletions syncer/src/main.rs
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ async fn main() -> Result<(), async_nats::Error> {
// Enable tracing.
tracing_subscriber::registry()
.with(EnvFilter::builder().with_default_directive(LevelFilter::INFO.into()).from_env_lossy())
.with(tracing_subscriber::fmt::layer())
.with(tracing_subscriber::fmt::layer().without_time().with_file(false).with_target(false))
.init();

// This returns an error if the `.env` file doesn't exist, but that's not what we want
@@ -81,7 +81,7 @@ async fn main() -> Result<(), async_nats::Error> {
// We don't want to crash the application because of a single message.
// We can always retry later, but the next time retry,
// the original intent may no longer be valid!!!
error!("Failed to handle message: {:?}", err);
error!("Failed to handle message: {}", err);
continue;
}
// Acknowledge the message if we handled it successfully.

0 comments on commit 571ff14

Please sign in to comment.