Compare commits
3 Commits
html_scrap
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5414a1bb26 | ||
|
|
c45001cb6d | ||
|
|
5fae51248a |
885
Cargo.lock
generated
885
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,8 @@ mwbot = { version = "0.7.0", default-features = false, features = ["generators",
|
|||||||
rand = "0.9.2"
|
rand = "0.9.2"
|
||||||
reqwest = "0.12.22"
|
reqwest = "0.12.22"
|
||||||
scraper = "0.24.0"
|
scraper = "0.24.0"
|
||||||
|
sentry = { version = "0.45.0", features = ["tracing"] }
|
||||||
|
sentry-tracing = { version = "0.45.0", features = ["backtrace", "logs"] }
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_plain = "1.0.2"
|
serde_plain = "1.0.2"
|
||||||
thiserror = "2.0.12"
|
thiserror = "2.0.12"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub enum DanceRank {
|
|||||||
Newcomer,
|
Newcomer,
|
||||||
Novice,
|
Novice,
|
||||||
Intermediate,
|
Intermediate,
|
||||||
#[serde(rename = "Advance")]
|
#[serde(rename = "Advance", alias = "Advanced")]
|
||||||
Advanced,
|
Advanced,
|
||||||
#[serde(rename = "All Star", alias = "All-Stars")]
|
#[serde(rename = "All Star", alias = "All-Stars")]
|
||||||
AllStars,
|
AllStars,
|
||||||
|
|||||||
47
src/main.rs
47
src/main.rs
@@ -24,6 +24,8 @@ use mwbot::{
|
|||||||
generators::{Generator, SortDirection, categories::CategoryMemberSort},
|
generators::{Generator, SortDirection, categories::CategoryMemberSort},
|
||||||
};
|
};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use tracing::level_filters::LevelFilter;
|
||||||
|
use tracing_subscriber::{Layer, layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
use crate::watchdog::watch_wanted;
|
use crate::watchdog::watch_wanted;
|
||||||
|
|
||||||
@@ -61,12 +63,47 @@ pub enum AppError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), AppError> {
|
fn main() -> Result<(), AppError> {
|
||||||
tracing_subscriber::fmt()
|
let fmt_filter = tracing_subscriber::fmt::layer().with_filter(
|
||||||
.with_level(true)
|
tracing_subscriber::EnvFilter::builder()
|
||||||
.with_max_level(tracing::Level::INFO)
|
.with_default_directive(LevelFilter::INFO.into())
|
||||||
.init();
|
.from_env_lossy(),
|
||||||
tracing::info!("Starting {}", app_signature());
|
);
|
||||||
|
let _guard = match std::fs::read_to_string("sentry_dsn.txt") {
|
||||||
|
Ok(dsn) => {
|
||||||
|
let guard = sentry::init((
|
||||||
|
dsn,
|
||||||
|
sentry::ClientOptions {
|
||||||
|
release: sentry::release_name!(),
|
||||||
|
traces_sample_rate: 1.0,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
|
let sentry_layer = sentry::integrations::tracing::layer()
|
||||||
|
.event_filter(|md| match *md.level() {
|
||||||
|
tracing::Level::ERROR => sentry_tracing::EventFilter::Event,
|
||||||
|
_ => sentry_tracing::EventFilter::Ignore,
|
||||||
|
})
|
||||||
|
.span_filter(|md| {
|
||||||
|
matches!(*md.level(), tracing::Level::ERROR | tracing::Level::WARN)
|
||||||
|
});
|
||||||
|
|
||||||
|
tracing_subscriber::registry()
|
||||||
|
.with(fmt_filter)
|
||||||
|
.with(sentry_layer)
|
||||||
|
.init();
|
||||||
|
tracing::info!("Starting {} with sentry", app_signature());
|
||||||
|
|
||||||
|
Some(guard)
|
||||||
|
}
|
||||||
|
Err(error) => {
|
||||||
|
tracing_subscriber::registry().with(fmt_filter).init();
|
||||||
|
tracing::warn!("Could not load 'sentry_dsn.txt': {}", error);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Register the Sentry tracing layer to capture breadcrumbs, events, and spans:
|
||||||
let rt = tokio::runtime::Builder::new_current_thread()
|
let rt = tokio::runtime::Builder::new_current_thread()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ pub enum DanceInfoError {
|
|||||||
ClientBuild(reqwest::Error),
|
ClientBuild(reqwest::Error),
|
||||||
#[error("Failed to build request: {0}")]
|
#[error("Failed to build request: {0}")]
|
||||||
RequestBuild(reqwest::Error),
|
RequestBuild(reqwest::Error),
|
||||||
#[error("Request error: {0}")]
|
#[error("Request error: {0:#?}")]
|
||||||
Request(reqwest::Error),
|
Request(reqwest::Error),
|
||||||
#[error("Failed to parse response: {0}")]
|
#[error("Failed to parse response: {0}")]
|
||||||
JsonParse(reqwest::Error),
|
JsonParse(reqwest::Error),
|
||||||
|
|||||||
Reference in New Issue
Block a user