godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.59k stars 21.1k forks source link

File logging log rotation is broken. #97066

Open Jack-023 opened 1 month ago

Jack-023 commented 1 month ago

Tested versions

v4.3.stable.arch_linux v4.2.2.stable.official [15073afe3]

System information

Godot v4.3.stable unknown - Arch Linux #1 SMP PREEMPT_DYNAMIC Thu, 12 Sep 2024 17:21:02 +0000 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3090 (nvidia; 560.35.03) - AMD Ryzen 7 5800X 8-Core Processor (16 Threads)

Issue description

When file debug/file_logging/enable_file_logging is enabled and debug/file_logging/max_log_files is > 1, files should be logged to the set directory (default "user://logs/godot.log") starting with godot.log (most recent run) and keeping previous runs as godot{datetimestamp}.log. Previously this would correctly maintain the most recent logs but since ~4.3 it has stopped working. Now once the first debug/file_logging/max_log_files have been generated, only the newest (godot.log) gets correctly replaced and the oldest n-1 files are kept forever.

Steps to reproduce

Enable file logging add some print statements and run the game 6 times.

Minimal reproduction project (MRP)

N/A

Calinou commented 1 month ago

@Jack-023 Can you try following the same steps on 4.3 dev/beta/RCs to determine when the regression started? You can download them here.

Jack-023 commented 1 month ago

@Calinou just tried Godot_v4.3-beta2_linux.x86_64 and the bug exists there.

Jack-023 commented 1 month ago

Actually just tested in v4.2.2.stable.official [15073afe3] in an older project and it's not working there either so it has been around longer than I thought.

Only godot.log gets overwritten, log files from months ago never change. I increased the file count from 5 -> 6 and ran a few more times. On the first run, godot.log was renamed with the correct datetime in the name and a new godot.log was created with the newest run. Second run none of the (now 5) files with a datetime in the name were updated/removed and godot.log was overwritten with the latest runs logs.