blenderlab / BattleIA

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

[TODO] Server : save logs to a file #23

Closed blenderlab closed 3 years ago

blenderlab commented 4 years ago

As a debug feature, server's log (messages on the screen) should be saved to a log file. The log file name should be unique (SERVER_datetime.log ?), and created when the server's simulation 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 :-1: 
   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 3 years ago

Seems done !