mirror of
https://github.com/10h30/kazewp.git
synced 2026-05-12 15:21:20 +09:00
Add logging function with improved output formatting
- Introduced a log() function to capture console output to a file - Added date separator and blank lines for better readability - Stripped ANSI color codes to avoid strange characters in the log
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
caddy/*
|
caddy/*
|
||||||
wordpress/*
|
wordpress/*
|
||||||
|
kazewp.log
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
LOG_FILE="kazewp.log"
|
||||||
|
exec > >(tee -a "$LOG_FILE") 2>&1
|
||||||
|
echo -e "\n========== $(date '+%Y-%m-%d %H:%M:%S') =========="
|
||||||
|
|
||||||
# Get the directory where the script is located
|
# Get the directory where the script is located
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
|||||||
+13
-4
@@ -1,4 +1,13 @@
|
|||||||
RED='\033[0;31m'
|
if [ -t 1 ]; then
|
||||||
GREEN='\033[0;32m'
|
# Terminal supports colors
|
||||||
BLUE='\033[0;34m'
|
NC='\033[0m' # No Color
|
||||||
NC='\033[0m' # No Color
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
else
|
||||||
|
# Disable colors for non-terminal outputs (like logs)
|
||||||
|
NC=''
|
||||||
|
RED=''
|
||||||
|
GREEN=''
|
||||||
|
BLUE=''
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user