feat: add option to include timestamp with init logs (#1332)

This commit is contained in:
Geoff Bourne 2022-02-05 12:27:17 -06:00 committed by GitHub
parent 4a1d2d2b80
commit 22f2eb7308
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 1 deletions

View File

@ -1559,6 +1559,20 @@ To enable the JVM flags required to fully support the [Flare profiling suite](ht
Flare is built-in to Airplane/Pufferfish/Purpur, and is available in [plugin form](https://github.com/TECHNOVE/FlarePlugin) for other server types.
### Enable timestamps in init logs
Before the container starts the Minecraft Server its output is prefixed with `[init]`, such as
```
[init] Starting the Minecraft server...
```
To also include the timestamp with each log, set `LOG_TIMESTAMP` to "true". The log output will then look like:
```
[init] 2022-02-05 16:58:33+00:00 Starting the Minecraft server...
```
## Autopause
### Description

View File

@ -40,6 +40,10 @@ function getFilenameFromUrl() {
}
function isTrue() {
local oldState
oldState=$(shopt -po xtrace)
shopt -u -o xtrace
local value=${1,,}
result=
@ -53,6 +57,7 @@ function isTrue() {
;;
esac
eval "$oldState"
return ${result}
}
@ -82,7 +87,18 @@ function logn() {
}
function log() {
echo "[init] $*"
local oldState
# The return status when listing options is zero if all optnames are enabled, non- zero otherwise.
oldState=$(shopt -po xtrace || true)
shopt -u -o xtrace
if isDebugging || isTrue "${LOG_TIMESTAMP:-false}"; then
ts=" $(date --rfc-3339=seconds)"
else
ts=
fi
echo "[init]${ts} $*"
eval "$oldState"
}
function logAutopause() {