Skip to content

Commit

Permalink
Merge pull request #102 from dandi/gh-101
Browse files Browse the repository at this point in the history
Use local timezone offset for log timestamps
  • Loading branch information
jwodder authored Mar 9, 2024
2 parents 03aab7a + d5ea38c commit 4d4dce0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ In Development
- Disable log coloration when stderr is not a terminal
- Suppress noisy & irrelevant log messages from various dependencies
- Log errors that cause 404 and 500 responses
- Use local timezone offset for log timestamps
- Added breadcrumbs to HTML views of collections
- `FAST_NOT_EXIST` components are now checked for case-insensitively
- Add links to version & asset metadata to the web view
Expand Down
12 changes: 12 additions & 0 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
Expand Up @@ -46,7 +46,7 @@ tokio = { version = "1.36.0", features = ["macros", "net", "rt-multi-thread"] }
tower = "0.4.13"
tower-http = { version = "0.5.2", features = ["set-header", "trace"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
tracing-subscriber = { version = "0.3.18", features = ["local-time", "time"] }
url = { version = "2.5.0", features = ["serde"] }
xml-rs = "0.8.19"

Expand Down
18 changes: 14 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::sync::Arc;
use tower::service_fn;
use tower_http::{set_header::response::SetResponseHeaderLayer, trace::TraceLayer};
use tracing::Level;
use tracing_subscriber::{filter::Targets, prelude::*};
use tracing_subscriber::{filter::Targets, fmt::time::OffsetTime, prelude::*};

static STYLESHEET: &str = include_str!("dav/static/styles.css");

Expand Down Expand Up @@ -64,12 +64,16 @@ struct Arguments {
title: String,
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let args = Arguments::parse();
// See
// <https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/time/struct.OffsetTime.html#method.local_rfc_3339>
// for an explanation of the main + #[tokio::main]run thing
fn main() -> anyhow::Result<()> {
let timer =
OffsetTime::local_rfc_3339().context("failed to determine local timezone offset")?;
tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::layer()
.with_timer(timer)
.with_ansi(stderr().is_terminal())
.with_writer(stderr),
)
Expand All @@ -82,6 +86,12 @@ async fn main() -> anyhow::Result<()> {
.with_default(Level::INFO),
)
.init();
run()
}

#[tokio::main]
async fn run() -> anyhow::Result<()> {
let args = Arguments::parse();
let dandi = DandiClient::new(args.api_url)?;
let zarrman = ZarrManClient::new()?;
let templater = Templater::load()?;
Expand Down

0 comments on commit 4d4dce0

Please sign in to comment.