Skip to content

Commit

Permalink
fix: add more detail to sentry logs (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler authored Oct 2, 2024
1 parent a63a948 commit 2cb554d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,4 @@ release-ci = ["tauri/custom-protocol"]
release-ci-beta = ["tauri/custom-protocol"]

[package.metadata.cargo-machete]
ignored = [
"log4rs",
"xz2",
"libsqlite3-sys",
"minotari_wallet_grpc_client",
"dirs-next",
]
ignored = ["log4rs", "xz2", "libsqlite3-sys", "minotari_wallet_grpc_client"]
17 changes: 16 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use log::trace;
use log::{debug, error, info, warn};
use sentry::protocol::Event;
use sentry_tauri::sentry;
use serde::Serialize;
use std::collections::HashMap;
use std::fs::{read_dir, remove_dir_all, remove_file};
Expand Down Expand Up @@ -1173,7 +1175,17 @@ async fn get_miner_metrics(
#[tauri::command]
fn log_web_message(level: String, message: Vec<String>) {
match level.as_str() {
"error" => error!(target: LOG_TARGET_WEB, "{}", message.join(" ")),
"error" => {
let joined_message = message.join(" ");
sentry::capture_event(Event {
message: Some(joined_message.clone()),
level: sentry::Level::Error,
culprit: Some("universe-web".to_string()),
..Default::default()
});
error!(target: LOG_TARGET_WEB, "{}", joined_message)
}

_ => info!(target: LOG_TARGET_WEB, "{}", message.join(" ")),
}
}
Expand Down Expand Up @@ -1351,6 +1363,8 @@ struct Payload {

#[allow(clippy::too_many_lines)]
fn main() {
// TODO: Integrate sentry into logs. Because we are using Tari's logging infrastructure, log4rs
// sets the logger and does not expose a way to add sentry into it.
let client = sentry_tauri::sentry::init((
"https://edd6b9c1494eb7fda6ee45590b80bcee@o4504839079002112.ingest.us.sentry.io/4507979991285760",
sentry_tauri::sentry::ClientOptions {
Expand Down Expand Up @@ -1444,6 +1458,7 @@ fn main() {
}))
.manage(app_state.clone())
.setup(|app| {
// TODO: Combine with sentry log
tari_common::initialize_logging(
&app.path_resolver()
.app_config_dir()
Expand Down

0 comments on commit 2cb554d

Please sign in to comment.