rush_sync_server/commands/log_level/
command.rs1use super::manager::LogLevelManager;
2use crate::commands::command::Command;
3use crate::core::prelude::*;
4
5#[derive(Debug)]
6pub struct LogLevelCommand;
7
8impl Command for LogLevelCommand {
9 fn name(&self) -> &'static str {
10 "log-level"
11 }
12
13 fn description(&self) -> &'static str {
14 "Change application log level"
15 }
16
17 fn matches(&self, command: &str) -> bool {
18 let cmd = command.trim().to_lowercase();
19 cmd.starts_with("log-level")
20 || cmd.starts_with("loglevel")
21 || (cmd.starts_with("config") && cmd.contains("--log-level"))
22 }
23
24 fn execute_sync(&self, args: &[&str]) -> Result<String> {
25 match args.first() {
26 None => Ok(LogLevelManager::show_status()),
27 Some(&"--help" | &"-h" | &"help") => Ok(LogLevelManager::show_help_i18n()),
28 Some(&level) => LogLevelManager::set_level_persistent(level),
29 }
30 }
31
32 fn priority(&self) -> u8 {
33 75
34 }
35}