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

Use common log prefix for window title #28

Closed
wants to merge 2 commits into from

Conversation

bryevdv
Copy link
Contributor

@bryevdv bryevdv commented Oct 9, 2023

This PR adds support to attempt to extract a common path prefix for log files provided on the command line, to use for the window title. If a common prefix is not determinable, the default "Legion Prof" is retained. cc @lightsighter

This PR also applies some some fixes advised by clippy regarding or_default.

cc @elliottslaughter is there a more robust rust solution for pruning command line options than this?

if !argument.starts_with("--") { ... }

Usage

Invoked with

RUST_BACKTRACE=1 target/debug/legion_prof --view ~/work/proflogs/231034/*.prof

produces:

Screenshot 2023-10-09 at 14 26 48

.unwrap()
.to_str()
.unwrap()
.to_string();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this makes sense, but also seems like a lot. If there is something better to do Rust-wise, please lmk.

@bryevdv bryevdv force-pushed the bv/profile-context branch from fd56b14 to 323c170 Compare October 9, 2023 21:37
@elliottslaughter
Copy link
Contributor

This is not going to work because we don't know how we're being called, or if the arguments are even being supplied on the command line. If we want to do this, we'll need to augment the DataSource interface to add a new trait method like:

fn get_source_path(&self) -> Option<PathBuf>;

Except I'm still not sure I'm happy with this because it might be a URL, not a Path at all. Maybe, to keep things consistent, we should just make this a String:

fn get_source_locator(&self) -> Option<String>;

And accept that the conversion into String will be lossy (i.e., not every Path can be converted to String because some OSes use non-UTF8 paths).

@bryevdv
Copy link
Contributor Author

bryevdv commented Oct 10, 2023

👍 That will be much cleaner

@bryevdv bryevdv closed this Nov 13, 2023
@bryevdv bryevdv deleted the bv/profile-context branch November 13, 2023 21:27
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

Successfully merging this pull request may close these issues.

2 participants