Feat: Fügt Log-Nachrichten in eine Log-Datei hinzu.
This commit is contained in:
parent
af5417c175
commit
50fccc03ab
@ -1,6 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# === Variablen ===
|
||||||
|
LOGDIR="/tmp/skript-logs"
|
||||||
|
LOGFILE="$LOGDIR/$(basename "$0" .sh)_$(date +'%Y-%m-%d').log"
|
||||||
|
|
||||||
# Funktion zum Protokollieren von Nachrichten
|
# Funktion zum Protokollieren von Nachrichten
|
||||||
log() {
|
log() {
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') - $1"
|
if [ ! -d "$LOGDIR" ]; then
|
||||||
|
mkdir -p "$LOGDIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOGFILE"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user