The script below will rotate logs for all currently connected worlds every day at midnight. If you're interested in timestamps in logs, there appears to be a patch for that.
Be sure to define LOGDIR before loading this script:
/def LOGDIR=~/tf/logs/
Log rotation script:
/def rotate_logs = \ /let _curworlds=$(/@listsockets -s) %;\ /eval /echo *** Rotating logs; current worlds: %{_curworlds} %;\ /while ( %{_curworlds} !~ "" ) \ /let _curworld=$(/car %{_curworlds}) %;\ /let _curworlds=$(/cdr %{_curworlds}) %;\ /log -w%{_curworld} off %;\ /log -w%{_curworld} ${LOGDIR}/$[ftime("%Y-%m-%d", time())]_%{_curworld}.log %;\ /done %;\ /unset _rotation_scheduled %;\ /schedule_rotation
/def -Fp50 schedule_rotation = \ /if (_rotation_scheduled) /return 0 %; /endif%;\ /set _rotation_scheduled=1 %;\ /at 00:00 /rotate_logs
/def -Fp100 -h'connect' connect_log = \ /log -w ${LOGDIR}/$[ftime("%Y-%m-%d", time())]_${world_name}.log %;\ /eval /echo -ag -w${world_name} *** ${world_name} log started $(/time %%c) *** %;\ /schedule_rotation
/def -Fp100 -h'disconnect' disconnect_log = \ /eval /echo -ag -w${world_name} *** ${world_name} log ended $(/time %%c) %;\ /log -w${world_name} off
/def -Fiq dc = /if /@dc %*%; /then trigger -hdisconnect %*%; /endif
I recommend combining this with the savehist.tf script. Put the following in your .tfrc to enable that:
/set savehist_dir=~/tf/histories/load savehist.tf/load_histories/repeat -0:05 i /save_histories_inc
Kenny Root
Copyright © Kenny Root. All rights reserved.