Any Windows wizards here?

psparky

King
Joined
Feb 24, 2011
Messages
624
I'm hoping someone can help me with a Windows problem.

I would like to analyze the log files for a full game, which typically takes me several weeks to play. However, each time Civ is restarted the logs get overwritten and, as I have to shut down my PC at the end of each day (not to mention the odd restart due to a crash), the data I would like isn't available.

What I'm envisaging is some sort of script (that I can invoke by double-clicking on a desktop icon) that would copy each individual log file to another folder (let's say a folder called gamelogs), appending it to any existing file of the same name in the destination folder. By using this script at the end of each session, it would gradually build a set of files containing the log data for the whole game.

I did a search and found some interesting snippets, but I don't really know the best way to even approach the problem, so I'm hoping someone can help me out. :)

I'm using Windows 10 Home Edition if that makes a difference. The files in question are all plain text, there can be hundreds of files, and the names can be different from game to game as, for example, some files are one per civ and include the civ name in the file name.
 
i would recommend making a script that saves the old logs every time you *start* the game.

```
copy-item path\to\logs\ -destination \path\to\backup-$(Get-Date -format "yyyy_MM_dd_hh_mm_ss")
start steam://rungameid/8930//\dx11
```
 
Well it is very easy to just get the logs, I made a quick script to do it but the realized that in many cases, like if you ran it twice, it would get the same log. And going through the very long logs and trying to see if there is a match would be difficult and intensive. So you would need to run it whenever the game starts I guess.

Tying it to when the game starts like ilteroi did seems like a better solution if that works.
 
i would recommend making a script that saves the old logs every time you *start* the game.

```
copy-item path\to\logs\ -destination \path\to\backup-$(Get-Date -format "yyyy_MM_dd_hh_mm_ss")
start steam://rungameid/8930//\dx11
```

Thank you! That certainly retains all the data and I can see the wisdom of doing it automatically.

That will leave me with many subdirectories each containing a set of logs. I'm still not sure of how to combine the multiple versions of each file together into a single set of files, with the data in each file in the correct order as it happened in the game.

That's a PowerShell script, right? Would that also be able to handle the combining function in another script?
 
you could try some backup software (I know Macrium Backup is free) it should be able to do what your looking for
 
Slightly off-topic:
In regards to determining if logs are duplicated, Notepad++ is a free alternative to Microsoft's Notepad and has a plugin available to do a 'Compare Files' which will automatically highlight any differences (I use it to alter .cfg files for small edits, such as map size changes to create a larger the huge map)
 
I made this, basically instead of using a shortcut of civ make a shortcut of this on your desktop and it will log the files into one file per log (so a lua.log, a database.log, an InstantYieldSummary.csv, all of them), then it will start the game (so that the logs are cleared, if the program somehow runs twice without civ reseting the logs then they will be duplicated).
Make sure to edit the file and add the directory of your logs folder and the game file.
 

Attachments

That's excellent - many thanks! :)

My friend has been telling me for at least 20 years to try Python and now I finally did.

If anyone else wants to try this, I'll just mention that it requires a Python interpreter - I got the one from Python.org

<Removed incorrect info>
 
Last edited:
Back
Top Bottom