Skip to content

Commit 7751948

Browse files
committed
feat: introduced overridable variable LOG_LEVEL
Now logging is only done when that variable is set
1 parent 66c9068 commit 7751948

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

APPw

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ APP_HOME="$HOME_DIR/$APP_DIR"
1313
# 2. Define default overridable variables
1414
# The update period in days (e.g., 3 means check if the last_checked file is older than 3 days)
1515
UPDATE_PERIOD=3
16+
# Logging level (default empty/silent; set to anything, e.g., 'DEBUG', to enable logging)
17+
LOG_LEVEL=
1618

1719
# --- Configuration Loading ---
1820
# Function to load configuration variables from a file
@@ -46,7 +48,10 @@ ARCHIVE_FILE="$CACHE_DIR/release.tgz"
4648
LAST_CHECKED_FILE="$CACHE_DIR/last_checked"
4749

4850
LOG() {
49-
echo "[Installer] $1"
51+
# Only echo the log message if LOG_LEVEL is not empty
52+
if [ -n "$LOG_LEVEL" ]; then
53+
echo "[Installer] $1"
54+
fi
5055
}
5156

5257
# Function to get the last modification timestamp of a file

APPw.cmd

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ set "APP_HOME=%HOME_DIR%\.%APP_DIR%"
1414
rem 2. Define default overridable variables
1515
rem The update period in days (e.g., 3 means check if the last_checked file is older than 3 days)
1616
set UPDATE_PERIOD=3
17+
rem Logging level (default empty/silent; set to anything, e.g., 'DEBUG', to enable logging)
18+
set LOG_LEVEL=
1719

1820
rem --- Configuration Loading ---
1921
rem Helper subroutine to load configuration from a file
@@ -50,7 +52,10 @@ set "LAST_CHECKED_FILE=%CACHE_DIR%\last_checked"
5052

5153
rem Helper function for logging
5254
:LOG
53-
echo [Installer] %~1
55+
rem Only echo the log message if LOG_LEVEL is not empty
56+
if not "%LOG_LEVEL%"=="" (
57+
echo [Installer] %~1
58+
)
5459
goto :eof
5560

5661
rem --- Core Logic Functions ---

0 commit comments

Comments
 (0)