]> git.corax.cc Git - toolbox/commitdiff
include/log: Add functions to increase and decrease the verbosity
authorMatthias Kruk <m@m10k.eu>
Thu, 15 Apr 2021 11:59:43 +0000 (20:59 +0900)
committerMatthias Kruk <m@m10k.eu>
Thu, 15 Apr 2021 11:59:43 +0000 (20:59 +0900)
I frequently find myself implementing the same functions to increase
and decrease the verbosity of my scripts. This commit adds these
functions to the log module.

include/log.sh

index c61b59998f84558c9042c3bffef64e4b50265dad..9718ab2fca4296636f8a5f8353100a77ff024314 100644 (file)
@@ -46,6 +46,26 @@ log_get_verbosity() {
        echo "$__log_verbosity"
 }
 
+log_increase_verbosity() {
+       local verb
+
+       verb=$(log_get_verbosity)
+       ((verb++))
+       log_set_verbosity "$verb"
+
+       return 0
+}
+
+log_decrease_verbosity() {
+       local verb
+
+       verb=$(log_get_verbosity)
+       ((verb--))
+       log_set_verbosity "$verb"
+
+       return 0
+}
+
 log_write() {
        local level
        local prefix