MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / level_matches

Function level_matches

crates/openshell-server/src/grpc/validation.rs:734–747  ·  view source on GitHub ↗

Check if a log line's level meets the minimum level threshold. Empty `min_level` means no filtering (all levels pass).

(log_level: &str, min_level: &str)

Source from the content-addressed store, hash-verified

732/// Check if a log line's level meets the minimum level threshold.
733/// Empty `min_level` means no filtering (all levels pass).
734pub(super) fn level_matches(log_level: &str, min_level: &str) -> bool {
735 if min_level.is_empty() {
736 return true;
737 }
738 let to_num = |s: &str| match s.to_uppercase().as_str() {
739 "ERROR" => 0,
740 "WARN" => 1,
741 "INFO" | "OCSF" => 2,
742 "DEBUG" => 3,
743 "TRACE" => 4,
744 _ => 5, // unknown levels always pass
745 };
746 to_num(log_level) <= to_num(min_level)
747}
748
749// ---------------------------------------------------------------------------
750// Tests

Callers 2

handle_get_sandbox_logsFunction · 0.85
handle_watch_sandboxFunction · 0.85

Calls 2

is_emptyMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected