In my current main project, I want all of my game’s output to be logged to file–and ideally all to a single file. It seems to me that, should I want to get output from users, log-files are likely to be much more convenient for them and more reliable for me–and much more so if there’s only one file to locate and send.
However, I’m really not sure that I’m approaching logging in a sensible manner, and could use some feedback and/or advice, please.
Here is what I’m currently doing:
I’m setting “Notify”'s output-stream pointer to a MultiplexStream that I instantiate, then setting “sys.stdout” and “sys.stderr” to new file-objects. All of the above point to the same file.
Common.nout = MultiplexStream() Notify.ptr().setOstreamPtr(Common.nout, 0) Common.nout.addFile(Filename(USER_DIR + "/logfile.txt")) sys.stdout = open(USER_DIR + "/logfile.txt", "w") sys.stderr = open(USER_DIR + "/logfile.txt", "w")
However, is it wise to have–presumably–three separate objects writing to the same file? I could perhaps use a single file-object for the two “sys”-variables, but I don’t know whether that’s a good idea, either. And indeed, I think that I’ve seen some cases of lines seeming to be cut off in part.
Furthermore, even the above doesn’t seem to catch quite everything–I believe that I’ve seen at least some output still being printed to terminal, and not ending up in the file.
So, is there a better way to go about this?