Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom path to save a panic report #167

Open
rucoder opened this issue Jan 28, 2025 · 1 comment
Open

Custom path to save a panic report #167

rucoder opened this issue Jan 28, 2025 · 1 comment

Comments

@rucoder
Copy link

rucoder commented Jan 28, 2025

Currently Report::persist uses env::temp_dir() to get a base folder to save a panic report

    /// Write a file to disk.
    pub fn persist(&self) -> Result<PathBuf, Box<dyn Error + 'static>> {
        let uuid = Uuid::new_v4().hyphenated().to_string();
        let tmp_dir = env::temp_dir();
        let file_name = format!("report-{}.toml", &uuid);
        let file_path = Path::new(&tmp_dir).join(file_name);
        let toml = self.serialize().expect("only using toml-compatible types");
        std::fs::write(&file_path, toml.as_bytes())?;
        Ok(file_path)
    }

However on some platforms TMPDIR may not be defined or be RO (yes, weird but true) . Sure TMPDIR may be overwritten when starting application however it would be nice to configure a base dir either as a parameter to ::handle_dump (breaking change) of through Metadata object

@epage
Copy link
Collaborator

epage commented Jan 28, 2025

If TMPDIR is not accessible, how do you plan to use a custom path to workaround the issue? I'm wondering if there is something to be generalized with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants