Browse Source

feat: Added Option to prefix logs with timestamps

pull/3795/head
Reda.drissi.e 4 years ago
parent
commit
c06a085262
  1. 4
      lgsm/config-default/config-lgsm/rustserver/_default.cfg
  2. 14
      lgsm/functions/command_start.sh

4
lgsm/config-default/config-lgsm/rustserver/_default.cfg

@ -198,3 +198,7 @@ postdetailslog="${lgsmlogdir}/${selfname}-postdetails.log"
lgsmlogdate="${lgsmlogdir}/${selfname}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
consolelogdate="${consolelogdir}/${selfname}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
gamelogdate="${gamelogdir}/${selfname}-game-$(date '+%Y-%m-%d-%H:%M:%S').log"
## Log Parameters
logts="False"
logtsformat="%Y-%m-%d %H:%M:%S"

14
lgsm/functions/command_start.sh

@ -8,6 +8,7 @@
commandname="START"
commandaction="Starting"
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
add_ts="gawk '{ print strftime(\\\"[$logtsformat]\\\"), \\\$0 }'"
fn_firstcommand_set
fn_start_teamspeak3(){
@ -92,8 +93,13 @@ fn_start_tmux(){
fn_script_log "tmux version: master (user compiled)"
echo -e "tmux version: master (user compiled)" >> "${consolelog}"
if [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then
tmux pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'"
if [ "$logts" == "True" ]; then
tmux pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $add_ts\" >> '${consolelog}'"
else
tmux pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'"
fi
fi
elif [ -n "${tmuxv}" ]; then
# tmux pipe-pane not supported in tmux versions < 1.6.
if [ "${tmuxvdigit}" -lt "16" ]; then
@ -108,7 +114,11 @@ fn_start_tmux(){
Currently installed: $(tmux -V)" > "${consolelog}"
# Console logging enable or not set.
elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then
tmux pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'"
if [ "$logts" == "True" ]; then
tmux pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $add_ts\" >> '${consolelog}'"
else
tmux pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'"
fi
fi
else
echo -e "Unable to detect tmux version" >> "${consolelog}"

Loading…
Cancel
Save