mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2024-06-07 19:40:43 +00:00
feat: add option to include timestamp with init logs (#1332)
This commit is contained in:
parent
4a1d2d2b80
commit
22f2eb7308
14
README.md
14
README.md
@ -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.
|
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
|
## Autopause
|
||||||
|
|
||||||
### Description
|
### Description
|
||||||
|
@ -40,6 +40,10 @@ function getFilenameFromUrl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isTrue() {
|
function isTrue() {
|
||||||
|
local oldState
|
||||||
|
oldState=$(shopt -po xtrace)
|
||||||
|
shopt -u -o xtrace
|
||||||
|
|
||||||
local value=${1,,}
|
local value=${1,,}
|
||||||
|
|
||||||
result=
|
result=
|
||||||
@ -53,6 +57,7 @@ function isTrue() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
eval "$oldState"
|
||||||
return ${result}
|
return ${result}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +87,18 @@ function logn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function log() {
|
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() {
|
function logAutopause() {
|
||||||
|
Loading…
Reference in New Issue
Block a user