Skip to content

Commit

Permalink
migrated to structured logging
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Sep 18, 2023
1 parent b19d0e3 commit 16beec6
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 62 deletions.
193 changes: 142 additions & 51 deletions server/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 server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lto = "thin"
[workspace.dependencies]
# logging/obeservability
log = "0.4.20"
env_logger = "0.10.0"
structured-logger = "1.0.3"
actix-web-prom = { version = "0.7.0", default-features = false, features = [] }

# runtime + webserver
Expand Down
2 changes: 1 addition & 1 deletion server/calendar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ path = "src/scraper.rs"
[dependencies]
# shared
log.workspace = true
env_logger.workspace = true
structured-logger.workspace = true
tokio.workspace = true
actix-web.workspace = true
actix-cors.workspace = true
Expand Down
7 changes: 6 additions & 1 deletion server/calendar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ async fn health_status_handler() -> HttpResponse {
}

use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use structured_logger::async_json::new_writer;
use structured_logger::Builder;

pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");

fn apply_db_migrations() {
Expand All @@ -32,7 +35,9 @@ fn apply_db_migrations() {

#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
Builder::with_level("info")
.with_target_writer("*", new_writer(tokio::io::stdout()))
.init();
apply_db_migrations();

// metrics
Expand Down
7 changes: 5 additions & 2 deletions server/calendar/src/scraper.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::scrape_task::ScrapeTask;
use log::{error, info};
use structured_logger::{async_json::new_writer, Builder};

use std::fmt;

use prometheus::labels;

mod models;
mod schema;
mod scrape_task;
Expand Down Expand Up @@ -40,7 +41,9 @@ impl fmt::Debug for TimeWindow {

#[tokio::main]
async fn main() {
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
Builder::with_level("info")
.with_target_writer("*", new_writer(tokio::io::stdout()))
.init();

let time_window = TimeWindow::init_from_env();
info!("Scraping time window: {time_window:?}");
Expand Down
2 changes: 1 addition & 1 deletion server/feedback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ path = "src/main.rs"
[dependencies]
# shared
log.workspace = true
env_logger.workspace = true
structured-logger.workspace = true
tokio.workspace = true
actix-web.workspace = true
actix-cors.workspace = true
Expand Down
Loading

0 comments on commit 16beec6

Please sign in to comment.