mirror of
https://github.com/10h30/kazewp.git
synced 2026-05-12 15:21:20 +09:00
Update README and restructure code
This commit is contained in:
+6
-17
@@ -13,22 +13,11 @@ if [ ! -w "$LOG_FILE" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Function to add timestamp to log file
|
||||
add_timestamp() {
|
||||
echo -e "\n========== $(date '+%Y-%m-%d %H:%M:%S') ==========" >> "$LOG_FILE"
|
||||
# Function to strip ANSI color codes
|
||||
strip_colors() {
|
||||
sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g"
|
||||
}
|
||||
|
||||
# Save original file descriptors
|
||||
exec 3>&1
|
||||
exec 4>&2
|
||||
|
||||
# Add timestamp to log file
|
||||
add_timestamp
|
||||
|
||||
# Setup logging while preserving read -p functionality:
|
||||
# Use process substitution for logging
|
||||
exec 1> >(tee >(sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> "$LOG_FILE"))
|
||||
exec 2> >(tee >(sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> "$LOG_FILE"))
|
||||
|
||||
# Restore original stdout for read commands
|
||||
export BASH_READ_FD=3
|
||||
# Redirect all output to both the terminal and the log file (without colors)
|
||||
exec > >(tee -a >(strip_colors >> "$LOG_FILE"))
|
||||
exec 2> >(tee -a >(strip_colors >> "$LOG_FILE") >&2)
|
||||
Reference in New Issue
Block a user