We have a socket server that, in addition to serving data, also writes logging statements to a file.
My question concerns the correctness of how it accesses the log file. The script is running continuously and all the log file IO stuff is inside the main 'while' loop. The file is opened, written to and closed during each iteration of the loop. This seems very inefficient to me, all the opening and closings I presume are IO intensive. Would placing the opening and closing of the filehandle outside the while loop be a good idea? thanks