Skip to content

Instantly share code, notes, and snippets.

@mirror-kt
Created October 6, 2025 01:30
Show Gist options
  • Select an option

  • Save mirror-kt/3340fd55c587a6a2372b663621c8ed3e to your computer and use it in GitHub Desktop.

Select an option

Save mirror-kt/3340fd55c587a6a2372b663621c8ed3e to your computer and use it in GitHub Desktop.
tracingで行番号を出すサンプル
use anyhow::{anyhow, Result};
use tracing::{instrument};
use tracing_subscriber;
#[instrument(err)]
fn always_err() -> Result<()> {
info!("test");
return Err(anyhow!("error"));
}
fn main() {
tracing_subscriber::fmt()
.event_format(
tracing_subscriber::fmt::format()
.with_file(true)
.with_line_number(true)
)
.init();
let _ = always_err();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment