-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove lazy_static
- Loading branch information
Showing
22 changed files
with
242 additions
and
177 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,67 @@ | ||
use lazy_static::lazy_static; | ||
use std::sync::OnceLock; | ||
|
||
use regex::Regex; | ||
|
||
use crate::{Error, Result}; | ||
|
||
lazy_static! { | ||
static ref NAME_BLOCKLIST: Vec<Regex> = [ | ||
"^___rust_try", | ||
"^__pthread", | ||
"^__clone", | ||
"^<loco_rs::errors::Error as", | ||
"^loco_rs::errors::Error::bt", | ||
/* | ||
"^<?tokio", | ||
"^<?future", | ||
"^<?tower", | ||
"^<?futures", | ||
"^<?hyper", | ||
"^<?axum", | ||
"<F as futures_core", | ||
"^<F as axum::", | ||
"^<?std::panic", | ||
"^<?core::", | ||
"^rust_panic", | ||
"^rayon", | ||
"^rust_begin_unwind", | ||
"^start_thread", | ||
"^call_once", | ||
"^catch_unwind", | ||
*/ | ||
] | ||
.iter() | ||
.map(|s| Regex::new(s).unwrap()) | ||
.collect::<Vec<_>>(); | ||
static ref FILE_BLOCKLIST: Vec<Regex> = ["axum-.*$", "tower-.*$", "hyper-.*$", "tokio-.*$", "futures-.*$", "^/rustc"] | ||
static NAME_BLOCKLIST: OnceLock<Vec<Regex>> = OnceLock::new(); | ||
static FILE_BLOCKLIST: OnceLock<Vec<Regex>> = OnceLock::new(); | ||
|
||
fn get_name_blocklist() -> &'static Vec<Regex> { | ||
NAME_BLOCKLIST.get_or_init(|| { | ||
[ | ||
"^___rust_try", | ||
"^__pthread", | ||
"^__clone", | ||
"^<loco_rs::errors::Error as", | ||
"^loco_rs::errors::Error::bt", | ||
/* | ||
"^<?tokio", | ||
"^<?future", | ||
"^<?tower", | ||
"^<?futures", | ||
"^<?hyper", | ||
"^<?axum", | ||
"<F as futures_core", | ||
"^<F as axum::", | ||
"^<?std::panic", | ||
"^<?core::", | ||
"^rust_panic", | ||
"^rayon", | ||
"^rust_begin_unwind", | ||
"^start_thread", | ||
"^call_once", | ||
"^catch_unwind", | ||
*/ | ||
] | ||
.iter() | ||
.map(|s| Regex::new(s).unwrap()) | ||
.collect::<Vec<_>>() | ||
}) | ||
} | ||
|
||
fn get_file_blocklist() -> &'static Vec<Regex> { | ||
FILE_BLOCKLIST.get_or_init(|| { | ||
[ | ||
"axum-.*$", | ||
"tower-.*$", | ||
"hyper-.*$", | ||
"tokio-.*$", | ||
"futures-.*$", | ||
"^/rustc", | ||
] | ||
.iter() | ||
.map(|s| Regex::new(s).unwrap()) | ||
.collect::<Vec<_>>(); | ||
.collect::<Vec<_>>() | ||
}) | ||
} | ||
|
||
pub fn print_backtrace(bt: &std::backtrace::Backtrace) -> Result<()> { | ||
backtrace_printer::print_backtrace(&mut std::io::stdout(), bt, &NAME_BLOCKLIST, &FILE_BLOCKLIST) | ||
.map_err(Error::msg) | ||
backtrace_printer::print_backtrace( | ||
&mut std::io::stdout(), | ||
bt, | ||
get_name_blocklist(), | ||
get_file_blocklist(), | ||
) | ||
.map_err(Error::msg) | ||
} |
This file contains 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
Oops, something went wrong.