fix: ротация логов вместо бесконечного роста файла (#885)#932
Open
f4rceful wants to merge 1 commit into
Open
Conversation
RotatingFileHandler only rotates when backupCount >= 1: CPython's doRollover skips the whole rotation block when backupCount == 0, so maxBytes is silently ignored and the active log grows forever. The tray hardcoded backupCount=0 and the CLI defaulted --log-backups to 0, so the configured size limit never applied — users reported logs ballooning to hundreds of MB (Flowseal#885). Centralize handler creation in utils/logging_setup.build_log_handler, which forces backupCount >= 1, and use it from both the tray and CLI log paths. Default --log-backups is now 1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что сделано
build_log_handler()вutils/logging_setup.py, которая гарантируетbackupCount >= 1— то есть ротация всегда активна.utils/tray_common.py) и консольный режим (proxy/tg_ws_proxy.py).--log-backupsподнят с0до1.Зачем
RotatingFileHandlerротирует файл только приbackupCount >= 1: в CPython методdoRolloverпропускает весь блок ротации, когдаbackupCount == 0(if self.backupCount > 0:). В этом случаеmaxBytesмолча игнорируется, и активный лог растёт без ограничений.Трей жёстко задавал
backupCount=0, а в консольном режиме--log-backupsпо умолчанию был0— поэтому заданный лимит размера не применялся никогда. Пользователи сообщали о логах, разрастающихся до сотен мегабайт (#885: 150 МБ, 600 МБ), при этом ручное ограничение размера не помогало, а перезапуск лишь временно обрезал файл.