Add additional panic information to panic events (#2555)
Adds the following to the panic event release_channel os_name os_version architecture Merge first: https://github.com/zed-industries/zed.dev/pull/322 Release Notes: - N/A
This commit is contained in:
commit
00265c19a0
2 changed files with 23 additions and 7 deletions
|
@ -6,6 +6,8 @@ use std::{env, fmt::Display};
|
||||||
use sysinfo::{System, SystemExt};
|
use sysinfo::{System, SystemExt};
|
||||||
use util::channel::ReleaseChannel;
|
use util::channel::ReleaseChannel;
|
||||||
|
|
||||||
|
// TODO: Move this file out of feedback and into a more general place
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
pub struct SystemSpecs {
|
pub struct SystemSpecs {
|
||||||
#[serde(serialize_with = "serialize_app_version")]
|
#[serde(serialize_with = "serialize_app_version")]
|
||||||
|
|
|
@ -70,10 +70,7 @@ fn main() {
|
||||||
log::info!("========== starting zed ==========");
|
log::info!("========== starting zed ==========");
|
||||||
let mut app = gpui::App::new(Assets).unwrap();
|
let mut app = gpui::App::new(Assets).unwrap();
|
||||||
|
|
||||||
let app_version = ZED_APP_VERSION
|
init_panic_hook(&app);
|
||||||
.or_else(|| app.platform().app_version().ok())
|
|
||||||
.map_or("dev".to_string(), |v| v.to_string());
|
|
||||||
init_panic_hook(app_version);
|
|
||||||
|
|
||||||
app.background();
|
app.background();
|
||||||
|
|
||||||
|
@ -376,19 +373,29 @@ struct Panic {
|
||||||
backtrace: Vec<String>,
|
backtrace: Vec<String>,
|
||||||
// TODO
|
// TODO
|
||||||
// stripped_backtrace: String,
|
// stripped_backtrace: String,
|
||||||
time: u128,
|
release_channel: String,
|
||||||
|
os_name: String,
|
||||||
|
os_version: Option<String>,
|
||||||
|
architecture: String,
|
||||||
|
panicked_on: u128,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct PanicRequest {
|
struct PanicRequest {
|
||||||
panic: Panic,
|
panic: Panic,
|
||||||
|
// TODO: Move to Panic struct, as app_version - requires changing zed.dev
|
||||||
version: String,
|
version: String,
|
||||||
token: String,
|
token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_panic_hook(app_version: String) {
|
fn init_panic_hook(app: &App) {
|
||||||
let is_pty = stdout_is_a_pty();
|
let is_pty = stdout_is_a_pty();
|
||||||
|
let platform = app.platform();
|
||||||
|
|
||||||
panic::set_hook(Box::new(move |info| {
|
panic::set_hook(Box::new(move |info| {
|
||||||
|
let app_version = ZED_APP_VERSION
|
||||||
|
.or_else(|| platform.app_version().ok())
|
||||||
|
.map_or("dev".to_string(), |v| v.to_string());
|
||||||
let backtrace = Backtrace::new();
|
let backtrace = Backtrace::new();
|
||||||
|
|
||||||
let thread = thread::current();
|
let thread = thread::current();
|
||||||
|
@ -414,7 +421,14 @@ fn init_panic_hook(app_version: String) {
|
||||||
.map(|line| line.to_string())
|
.map(|line| line.to_string())
|
||||||
.collect(),
|
.collect(),
|
||||||
// modified_backtrace: None,
|
// modified_backtrace: None,
|
||||||
time: SystemTime::now()
|
release_channel: RELEASE_CHANNEL.dev_name().into(),
|
||||||
|
os_name: platform.os_name().into(),
|
||||||
|
os_version: platform
|
||||||
|
.os_version()
|
||||||
|
.ok()
|
||||||
|
.map(|os_version| os_version.to_string()),
|
||||||
|
architecture: env::consts::ARCH.into(),
|
||||||
|
panicked_on: SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_millis(),
|
.as_millis(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue