blenderlab / BattleIA

Client/Server app for Adimaker IT curses
2 stars 19 forks source link

[TODO] Bot : save logs to a file #22

Open blenderlab opened 4 years ago

blenderlab commented 4 years ago

As a debug feature, bot's log (messages on the screen) should be saved to a log file. The log file name should be unique (_botnamedatetime.log ?), and created when the bot is launched. The Console.Writline messages has to be written in this file.

Perhaps a configuration flag should be used : log_to_text = True so a function can be written, here in pseudo-code:

function log_message (message) : 
    if log_to_text is True : 
         write_to_file(logfile, message)
    print_to_screen(message)

This function could replace all the "Console.WriteLine" lines in the code !

You can imagine to timestamp all messages, of course.

For advice : https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-write-to-a-text-file

blenderlab commented 4 years ago

Error when 2 instances of same bot is launched : the log file is not accessible. We need a file per instance (GUID?)