• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OpenTibia Server Console Logger

Infernum

Senator
Joined
Feb 14, 2015
Messages
5,643
Solutions
559
Reaction score
3,948
For users that don't have Python 3.6 installed on their system, I provided a rar file with a Python executable that will be able to run without Python being installed.
It is by no means required to use the executable, if you have Python installed all you need to do is use this script (this is also the executable's source)
Python:
import subprocess
import time
import os

DIR = os.getcwd()
EXE = "theforgottenserver.exe"

TFS = subprocess.Popen(DIR + "/" + EXE, cwd=DIR, stdout=subprocess.PIPE)
timestamp = time.strftime("%m-%e-%G", time.localtime())
filename = DIR + "/logs/tfs log " + timestamp + ".txt"

if not os.path.exists(filename):
    os.mkdir(os.path.dirname(filename))

with open(filename, "a") as file:
    for line in TFS.stdout:
        txt = line.decode().strip()
        file.write("{} | {}\n".format(time.strftime("%H:%M:%S", time.localtime()), txt))
        print(txt)
        file.flush()

    file.write(time.strftime("%H:%M:%S", time.localtime()) + " | Server Closed\n\n\n")
Simply put the script or executable in your server's directory where your TFS executable is and run it.
This will run TFS itself, so there is no need to start TFS on your own after running the script/executable.
The output of the logs will be inside of a folder called "logs" in your server's directory, with the name "tfs log month-day-year"
If you desire the date output to be day-month-year, change "%m-%e-%G" to "%e-%m-%G" in the script.
 

Attachments

Have from linux ?
did you run the script manually with python3 in linux?
any errors or anything? i don't have a linux VM to test this stuff on so i didn't release it as linux-compatible
 
Back
Top