]> git.seodisparate.com - mpd_info_screen/commitdiff
Differentiate between log level/state, bump version 0.2.9
authorStephen Seo <seo.disparate@gmail.com>
Fri, 7 Jan 2022 07:05:37 +0000 (16:05 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 7 Jan 2022 07:07:15 +0000 (16:07 +0900)
Cargo.lock
Cargo.toml
README.md
src/debug_log.rs
src/main.rs
src/mpd_handler.rs

index 3cef8d0335a6755d9bf84a3e58aae1a55d649461..38f9046741ddc4c4fa6ef64dbb756048b7bf0208 100644 (file)
@@ -1427,7 +1427,7 @@ dependencies = [
 
 [[package]]
 name = "mpd_info_screen"
-version = "0.2.8"
+version = "0.2.9"
 dependencies = [
  "ggez",
  "image",
index 0e6fc006bfd01d6641e652b9f5e5787dc4e5ac32..970e91381c206b9f38204d89d53706713c0edae4 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "mpd_info_screen"
-version = "0.2.8"
+version = "0.2.9"
 edition = "2018"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
index bdb3d8880565b28e0fe98ef76fee9eacd9674419..ae804473d7a59ecbb37fabaa47910d8bbef196cd 100644 (file)
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ counter, and the filename currently being played
 
 # Usage
 
-    mpd_info_screen 0.2.8
+    mpd_info_screen 0.2.9
     
     USAGE:
         mpd_info_screen [FLAGS] [OPTIONS] <host> [port]
index 90b7200ea29c78781431ebf6b1c0408c5005b0ad..9778cf4b460183d107153a21e38afa75f320eab5 100644 (file)
@@ -1,9 +1,17 @@
 use std::fmt::Display;
 use structopt::clap::arg_enum;
 
+#[derive(Copy, Clone, Debug, PartialEq)]
+pub enum LogState {
+    ERROR,
+    WARNING,
+    DEBUG,
+    VERBOSE,
+}
+
 arg_enum! {
     #[derive(Copy, Clone, Debug, PartialEq)]
-    pub enum LogState {
+    pub enum LogLevel {
         ERROR,
         WARNING,
         DEBUG,
@@ -11,22 +19,22 @@ arg_enum! {
     }
 }
 
-pub fn log<T>(msg: T, level: LogState, state: LogState)
+pub fn log<T>(msg: T, state: LogState, level: LogLevel)
 where
     T: Display,
 {
-    if level == LogState::ERROR {
+    if state == LogState::ERROR {
         log_error(msg);
-    } else if level == LogState::WARNING {
-        if state != LogState::ERROR {
+    } else if state == LogState::WARNING {
+        if level != LogLevel::ERROR {
             log_warning(msg);
         }
-    } else if level == LogState::DEBUG {
-        if state == LogState::DEBUG || state == LogState::VERBOSE {
+    } else if state == LogState::DEBUG {
+        if level == LogLevel::DEBUG || level == LogLevel::VERBOSE {
             log_debug(msg);
         }
-    } else if level == LogState::VERBOSE {
-        if state == LogState::VERBOSE {
+    } else if state == LogState::VERBOSE {
+        if level == LogLevel::VERBOSE {
             log_verbose(msg);
         }
     } else {
index 07dceaa3acdcbca135540cf78eeaa509415921b6..483183c16cde4ab14b1b91fb112c35920faeb8dd 100644 (file)
@@ -38,11 +38,11 @@ pub struct Opt {
     #[structopt(
         short = "l",
         long = "log-level",
-        possible_values = &debug_log::LogState::variants(),
+        possible_values = &debug_log::LogLevel::variants(),
         default_value = "ERROR",
         case_insensitive = true,
     )]
-    log_level: debug_log::LogState,
+    log_level: debug_log::LogLevel,
 }
 
 fn main() -> Result<(), String> {
index b475a6c44c1e771ea4aecab594cdfdb920a3628d..f35588a0fd21594617bc0d221d02b224c79cd0f0 100644 (file)
@@ -1,4 +1,4 @@
-use crate::debug_log::{log, LogState};
+use crate::debug_log::{log, LogLevel, LogState};
 use std::io::{self, Read, Write};
 use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpStream};
 use std::str::FromStr;
@@ -65,7 +65,7 @@ pub struct MPDHandlerState {
     self_thread: Option<Arc<Mutex<thread::JoinHandle<Result<(), String>>>>>,
     dirty_flag: Arc<AtomicBool>,
     pub stop_flag: Arc<AtomicBool>,
-    log_level: LogState,
+    log_level: LogLevel,
 }
 
 fn check_next_chars(
@@ -228,7 +228,7 @@ impl MPDHandler {
         host: Ipv4Addr,
         port: u16,
         password: String,
-        log_level: LogState,
+        log_level: LogLevel,
     ) -> Result<Self, String> {
         let stream = TcpStream::connect_timeout(
             &SocketAddr::new(IpAddr::V4(host), port),