Skip to content

Commit

Permalink
feat: change loogging to json (#83)
Browse files Browse the repository at this point in the history
* feat: change loogging to json

* fix: fix formatting
  • Loading branch information
eiunkar authored Jan 16, 2025
1 parent 3f992fe commit 575711c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ tracing = { version = "0.1", features = [
"max_level_debug",
"release_max_level_info",
] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt", "json"] }
tracing-test = "0.2"
tui-input = "0.11.0"
tui-logger = { version = "0.14", features = ["tracing-support"] }
Expand Down
2 changes: 1 addition & 1 deletion affinidi-messaging-mediator/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub async fn start() {
let ansi = env::var("LOCAL").is_ok();
tracing_subscriber::registry()
.with(filter)
.with(tracing_subscriber::fmt::layer().with_ansi(ansi))
.with(tracing_subscriber::fmt::layer().with_ansi(ansi).json())
.init();

if ansi {
Expand Down
34 changes: 32 additions & 2 deletions affinidi-messaging-mediator/src/tasks/statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,38 @@ pub async fn statistics(database: DatabaseHandler) -> Result<(), MediatorError>
loop {
interval.tick().await;
let stats = database.get_db_metadata().await?;
info!("Statistics: {}", stats);
info!("Delta: {}", stats.delta(&previous_stats));
let delta = stats.delta(&previous_stats);
info!(
event_type = "UpdateStats",
received_bytes = stats.received_bytes,
sent_bytes = stats.sent_bytes,
deleted_bytes = stats.deleted_bytes,
received_count = stats.received_count,
sent_count = stats.sent_count,
deleted_count = stats.deleted_count,
websocket_open = stats.websocket_open,
websocket_close = stats.websocket_close,
sessions_created = stats.sessions_created,
sessions_success = stats.sessions_success,
oob_invites_created = stats.oob_invites_created,
oob_invites_claimed = stats.oob_invites_claimed
);

info!(
event_type = "UpdateDeltaStats",
received_bytes = delta.received_bytes,
sent_bytes = delta.sent_bytes,
deleted_bytes = delta.deleted_bytes,
received_count = delta.received_count,
sent_count = delta.sent_count,
deleted_count = delta.deleted_count,
websocket_open = delta.websocket_open,
websocket_close = delta.websocket_close,
sessions_created = delta.sessions_created,
sessions_success = delta.sessions_success,
oob_invites_created = delta.oob_invites_created,
oob_invites_claimed = delta.oob_invites_claimed
);

previous_stats = stats;
}
Expand Down

0 comments on commit 575711c

Please sign in to comment.