json api cli working
This commit is contained in:
@@ -64,19 +64,33 @@ impl VeilidLogLevel {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for VeilidLogLevel {
|
||||
type Err = VeilidAPIError;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Ok(match s {
|
||||
"Error" => Self::Error,
|
||||
"Warn" => Self::Warn,
|
||||
"Info" => Self::Info,
|
||||
"Debug" => Self::Debug,
|
||||
"Trace" => Self::Trace,
|
||||
_ => {
|
||||
apibail_invalid_argument!("Can't convert str", "s", s);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
impl fmt::Display for VeilidLogLevel {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
let text = match self {
|
||||
Self::Error => "ERROR",
|
||||
Self::Warn => "WARN",
|
||||
Self::Info => "INFO",
|
||||
Self::Debug => "DEBUG",
|
||||
Self::Trace => "TRACE",
|
||||
Self::Error => "Error",
|
||||
Self::Warn => "Warn",
|
||||
Self::Info => "Info",
|
||||
Self::Debug => "Debug",
|
||||
Self::Trace => "Trace",
|
||||
};
|
||||
write!(f, "{}", text)
|
||||
}
|
||||
}
|
||||
|
||||
/// A VeilidCore log message with optional backtrace
|
||||
#[derive(
|
||||
Debug,
|
||||
|
@@ -545,6 +545,35 @@ impl Default for VeilidConfigLogLevel {
|
||||
Self::Off
|
||||
}
|
||||
}
|
||||
impl FromStr for VeilidConfigLogLevel {
|
||||
type Err = VeilidAPIError;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Ok(match s {
|
||||
"Off" => Self::Off,
|
||||
"Error" => Self::Error,
|
||||
"Warn" => Self::Warn,
|
||||
"Info" => Self::Info,
|
||||
"Debug" => Self::Debug,
|
||||
"Trace" => Self::Trace,
|
||||
_ => {
|
||||
apibail_invalid_argument!("Can't convert str", "s", s);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
impl fmt::Display for VeilidConfigLogLevel {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
let text = match self {
|
||||
Self::Off => "Off",
|
||||
Self::Error => "Error",
|
||||
Self::Warn => "Warn",
|
||||
Self::Info => "Info",
|
||||
Self::Debug => "Debug",
|
||||
Self::Trace => "Trace",
|
||||
};
|
||||
write!(f, "{}", text)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Default,
|
||||
|
Reference in New Issue
Block a user