mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-25 23:45:39 +00:00
LOGGER: fixed debug colorization
This commit is contained in:
parent
28550e33ac
commit
e365c41cd6
6
functions/logger.sh
Normal file → Executable file
6
functions/logger.sh
Normal file → Executable file
|
@ -1,3 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
# This script provides a logging function 'log' that can be sourced in other scripts.
|
# This script provides a logging function 'log' that can be sourced in other scripts.
|
||||||
# It logs messages to both the terminal and a specified logfile, allowing different log levels.
|
# It logs messages to both the terminal and a specified logfile, allowing different log levels.
|
||||||
# The log function takes three parameters: log level, log message, and optionally the logfile. If no logfile is specified, it writes to retrodeck/logs/retrodeck.log
|
# The log function takes three parameters: log level, log message, and optionally the logfile. If no logfile is specified, it writes to retrodeck/logs/retrodeck.log
|
||||||
|
@ -30,9 +32,9 @@ log() {
|
||||||
echo "$timestamp $colored_message" | tee -a >(sed $'s,\e\\[[0-9;]*[a-zA-Z],,g' >> "$logfile")
|
echo "$timestamp $colored_message" | tee -a >(sed $'s,\e\\[[0-9;]*[a-zA-Z],,g' >> "$logfile")
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
# Debug (green) for both terminal and log file
|
# Debug (green) for both terminal, no color for log file
|
||||||
colored_message="\e[32m[DEBUG]\e[0m $message"
|
colored_message="\e[32m[DEBUG]\e[0m $message"
|
||||||
echo "$timestamp $colored_message" | tee -a "$logfile"
|
echo "$timestamp $colored_message" | tee -a >(sed $'s,\e\\[[0-9;]*[a-zA-Z],,g' >> "$logfile")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Default (no color)
|
# Default (no color)
|
||||||
|
|
Loading…
Reference in a new issue