Skip to content

Commit

Permalink
Fix logging to syslog
Browse files Browse the repository at this point in the history
  • Loading branch information
brablc committed May 30, 2024
1 parent cac4c50 commit d78bf17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ WEBROOT="/tmp/webroot"
ACME_PATH=".well-known/acme-challenge"
LOCK_FILE="/tmp/certbot.lck"

LOGGER_USE_TS=1
SCRIPT_NAME=${0##*/}

mkdir -p "$WEBROOT/$ACME_PATH" "$LE_DIR/failed"
echo "ok" > "$WEBROOT/$ACME_PATH/test.txt"
12 changes: 8 additions & 4 deletions logger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ log() {
esac

reset=$'\e[39m'
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
if [[ -n $LOGGER_USE_TS ]]; then
timestamp=$(date +"%Y-%m-%d %H:%M:%S|")
else
timestamp=""
fi

if [[ -t 1 || -n $CONTENT_TYPE ]]; then
echo -e "${color}-${level:0:1}|${timestamp}|${message}${reset}"
echo -e "${color}-${level:0:1}|${timestamp}${message}${reset}"
else
echo "-${level:0:1}|${timestamp}|${message}"
echo "-${level:0:1}|${timestamp}${message}"
fi

logger -t SCRIPT_NAME -p user.${level,,} "${timestamp} - ${level} - ${message}"
logger -t $SCRIPT_NAME -p user.${level,,} "${level} - ${message}"
}

log_info() {
Expand Down

0 comments on commit d78bf17

Please sign in to comment.