Created
October 6, 2025 01:30
-
-
Save mirror-kt/3340fd55c587a6a2372b663621c8ed3e to your computer and use it in GitHub Desktop.
tracingで行番号を出すサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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