Printing to the log in BF1

Started by BAD_AL, September 14, 2021, 10:27:09 PM

Previous topic - Next topic

BAD_AL

September 14, 2021, 10:27:09 PM Last Edit: September 14, 2021, 10:36:57 PM by BAD_AL
As a BF2 modder I was kind of shocked to find out that the print statements in BF1 didn't go to the BFront.log file like they do in BF2.

Phantom mentioned that although the print statements don't go to the log, we do have the ability to read and write files.

So if you want to get your print statements to a log for debugging you can add this code to your addme or mission file for better debugging:
debug_log = openfile("BFrontDebug.log", "w+")
old_print = print
print = function( arg1, arg2, arg3, arg4)
local print_this = arg1 .. (arg2 or "" ) .. (arg3 or "") .. (arg4 or "") .. " \n"
write(debug_log, print_this)
flush()
old_print(arg)
end
It also works for the game exe (non-steam).
You may have to wait until the game exits for it to write to the file.