Repository: godot
Issue: Very large godot.log file makes godot use 100% CPU and get stuck
Labels: bug,topic:core

<!-- Please search existing issues for potential duplicates before filing yours:
https://github.com/godotengine/godot/issues?q=is%3Aissue
-->
Sort of related open issue but not really https://github.com/godotengine/godot/issues/21895
**Godot Version**
```
godot --version
3.3.stable.arch_linux
```
Installed via pacman on arch
<!-- Specify commit hash if using non-official build. -->


**OS/device including version:**
<!-- Specify GPU model, drivers, and the backend (GLES2, GLES3, Vulkan) if graphics-related. -->
```
alex@moby logs (main) $ neofetch
                   -`                    alex@moby
                  .o+`                   ---------
                 `ooo/                   OS: Arch Linux x86_64
                `+oooo:                  Host: UX410UQK 1.0
               `+oooooo:                 Kernel: 5.12.3-arch1-1
               -+oooooo+:                Uptime: 13 hours, 6 mins
             `/:-:++oooo+:               Packages: 827 (pacman)
            `/++++/+++++++:              Shell: bash 5.1.8
           `/++++++++++++++:             Resolution: 1920x1080, 3840x2160, 1920x1080
          `/+++ooooooooooooo/`           DE: Plasma 5.21.5
         ./ooosssso++osssssso+`          WM: KWin
        .oossssso-````/ossssss+`         WM Theme: plastik
       -osssssso.      :ssssssso.        Theme: Breeze Dark [Plasma], Breeze [GTK2/3]
      :osssssss/        osssso+++.       Icons: breeze-dark [Plasma], breeze-dark [GTK2/3]
     /ossssssss/        +ssssooo/-       Terminal: alacritty
   `/ossssso+/:-        -:/+osssso+-     Terminal Font: black: '
  `+sso+:-`                 `.-/+oso:    CPU: Intel i7-7500U (4) @ 3.500GHz
 `++:.                           `-/+/   GPU: NVIDIA GeForce 940MX
 .`                                 `/   GPU: Intel HD Graphics 620
                                         Memory: 7318MiB / 15885MiB
```




**Issue description:**
<!-- What happened, and what was expected. -->
I could not start debugging my game in my game project folder. The launched debugger would gobble an entire core at 100%, making my laptop fan go crazy. It was in that state before i manually killed the process. Other example projects worked fine though, so it was an issue with my project. Editor worked fine when launched somewhere else than the folder my game was in. 

Turns out the godot.log in 
`/home/alex/.local/share/godot/app_userdata/<game_name>/logs`
was really huge. 1.7GB. The issue was with a variable that I had configured incorrectly, making godot run into a loop when running tests with GUT I think. (I can't reproduce the actual generation of the log file).

Moving the godot.log from the `logs` folder solved the problem. Then godot could just generate a new godot.log file for its output when running a project. 

Does godot parse the existing godot.log file on boot before overwriting? 

It looks like it copies the godot.log for the log rotation, which is what takes a lot of CPU until it is completed.

**Steps to reproduce:**
1. Create a blank project that can run
2. generate large bogus data in the logs folder for example with `yes "Some text" | head -n 100000000 > godot.log` which creates a 1GB~ text file with trash data
3. Run the project

**Minimal reproduction project:**
<!-- A small Godot project which reproduces the issue. Drag and drop a zip archive to upload it. -->
See above, any project works and the issue is with the godot.log file and not the code in the project. 

**Potential steps to fix**
I am not familiar with C++, so I don't think I could without a lot of hand holding. I did a grep on the logger function and closest I came to the relevant function was this: https://github.com/godotengine/godot/blob/37c3b332538c81ef02c8e5b8d1be979b78d1aaa4/core/os/os.cpp#L98

Feel free to use me as a rubberduck for discussing the issue. I think godot is awesome and the people that maintain it is even more awesome! :)