aboutsummaryrefslogtreecommitdiffstats
path: root/ports/servoshell/prefs.rs
diff options
context:
space:
mode:
authorAstraea Quinn S <52372765+PartiallyUntyped@users.noreply.github.com>2025-04-15 12:19:13 +0200
committerGitHub <noreply@github.com>2025-04-15 10:19:13 +0000
commit064f82d0a3ccc5f964e0a161d891b53a692d0729 (patch)
tree2c879e13791bf69c72b594d717dc79daf222557c /ports/servoshell/prefs.rs
parent1ea80c4335f7858f0550832e92635e3682ac5b0e (diff)
downloadservo-064f82d0a3ccc5f964e0a161d891b53a692d0729.tar.gz
servo-064f82d0a3ccc5f964e0a161d891b53a692d0729.zip
[OHOS] Allow setting the log-filter via cli arguments (#36444)
This PR allows setting the log-filter according to the env_filter spec via CLI arguments. Testing is currently in progress, will be done on machines running OHOS. --------- Signed-off-by: Astraea Quinn Skoutelli <astraea.quinn.skoutelli@huawei.com> Co-authored-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Diffstat (limited to 'ports/servoshell/prefs.rs')
-rw-r--r--ports/servoshell/prefs.rs27
1 files changed, 23 insertions, 4 deletions
diff --git a/ports/servoshell/prefs.rs b/ports/servoshell/prefs.rs
index 2bd95398f63..7eae7a3850c 100644
--- a/ports/servoshell/prefs.rs
+++ b/ports/servoshell/prefs.rs
@@ -57,6 +57,11 @@ pub(crate) struct ServoShellPreferences {
/// Where to load userscripts from, if any.
/// and if the option isn't passed userscripts won't be loaded.
pub userscripts_directory: Option<PathBuf>,
+
+ /// Log filter given in the `log_filter` spec as a String, if any.
+ /// If a filter is passed, the logger should adjust accordingly.
+ #[cfg(target_env = "ohos")]
+ pub log_filter: Option<String>,
}
impl Default for ServoShellPreferences {
@@ -75,6 +80,8 @@ impl Default for ServoShellPreferences {
output_image_path: None,
exit_after_stable_image: false,
userscripts_directory: None,
+ #[cfg(target_env = "ohos")]
+ log_filter: None,
}
}
}
@@ -348,6 +355,14 @@ pub(crate) fn parse_command_line_arguments(args: Vec<String>) -> ArgumentParsing
"FILTER",
);
+ #[cfg(target_env = "ohos")]
+ opts.optmulti(
+ "",
+ "log-filter",
+ "Define a custom filter for logging.",
+ "FILTER",
+ );
+
opts.optflag(
"",
"enable-experimental-web-platform-features",
@@ -408,10 +423,12 @@ pub(crate) fn parse_command_line_arguments(args: Vec<String>) -> ArgumentParsing
}
// Env-Filter directives are comma seperated.
let filters = opt_match.opt_strs("tracing-filter").join(",");
- let tracing_filter = if filters.is_empty() {
- None
- } else {
- Some(filters)
+ let tracing_filter = (!filters.is_empty()).then_some(filters);
+
+ #[cfg(target_env = "ohos")]
+ let log_filter = {
+ let filters = opt_match.opt_strs("log-filter").join(",");
+ (!filters.is_empty()).then_some(filters)
};
let mut debug_options = DebugOptions::default();
@@ -626,6 +643,8 @@ pub(crate) fn parse_command_line_arguments(args: Vec<String>) -> ArgumentParsing
userscripts_directory: opt_match
.opt_default("userscripts", "resources/user-agent-js")
.map(PathBuf::from),
+ #[cfg(target_env = "ohos")]
+ log_filter,
..Default::default()
};