File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed
Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ use serde_json::{json, Value};
5858use std:: borrow:: Cow ;
5959use std:: convert:: TryFrom ;
6060use std:: io:: Write ;
61+ use std:: str:: FromStr ;
6162use std:: sync:: Arc ;
6263
6364pub enum PageContext {
@@ -730,16 +731,6 @@ impl<W: std::io::Write> HtmlRenderContext<W> {
730731 component. starts_with ( LOG_COMPONENT )
731732 }
732733
733- fn string_to_log_level ( log_level_string : & str ) -> log:: Level {
734- match log_level_string {
735- "error" => log:: Level :: Error ,
736- "warn" => log:: Level :: Warn ,
737- "trace" => log:: Level :: Trace ,
738- "debug" => log:: Level :: Debug ,
739- _ => log:: Level :: Info ,
740- }
741- }
742-
743734 fn handle_log_component ( data : & JsonValue ) -> anyhow:: Result < ( ) > {
744735 let object_map: & serde_json:: Map < String , JsonValue > = match data {
745736 JsonValue :: Object ( object) => object,
@@ -750,7 +741,11 @@ impl<W: std::io::Write> HtmlRenderContext<W> {
750741
751742 let log_level: log:: Level = match object_map. get ( LOG_PRIORITY_KEY ) {
752743 Some ( Value :: String ( priority) ) => {
753- Self :: string_to_log_level ( priority. clone ( ) . to_lowercase ( ) . as_str ( ) )
744+ if let Ok ( level) = log:: Level :: from_str ( & priority. clone ( ) ) {
745+ level
746+ } else {
747+ log:: Level :: Info
748+ }
754749 }
755750 _ => log:: Level :: Info ,
756751 } ;
You can’t perform that action at this time.
0 commit comments