Skip to content

Logs not rotating #2549

Description

@BrutuZ

Expected behaviour:

Logs to be properly rotated from flexget.log to flexget.log.1-9 when reaching the criteria

Actual behaviour:

Loguru tells it can't rotate flexget.log because the file is supposedly in use by another application, copies it to the same folder appending a timestamp to the filename and flexget.log is neither erased nor updated.

Steps to reproduce:

  • Step 1: Fill flexget.log close to the 1MB rotation mark
  • Step 2: Have the Flexget daemon in Windows fill the remaining bytes to trigger a log rotation

Log:

(click to expand)
--- Logging error in Loguru Handler #3 ---
Record was: {'elapsed': datetime.timedelta(seconds=62, microseconds=308763), 'exception': None, 'extra': {'task': 'clean-anime-series-list', 'session_id': None, 'task_id': '121378'}, 'file': (name='verbose_details.py', path='%USERPROFILE%\\github\\flexget\\flexget\\plugins\\operate\\verbose_details.py'), 'function': 'on_task_download', 'level': (name='VERBOSE', no=15, icon='?'), 'line': 36, 'message': 'Summary - Accepted: 0 (Rejected: 0 Undecided: 0 Failed:
0)', 'module': 'verbose_details', 'name': 'details', 'process': (id=9684, name='MainProcess'), 'thread': (id=9940, name='task_queue'), 'time': datetime(2019, 12, 30, 0, 33, 26, 805511, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=75600), 'E. South America Standard Time'))}
Traceback (most recent call last):
  File "%USERPROFILE%\github\flexget\lib\site-packages\loguru\_handler.py", line 153, in emit
    self._sink.write(str_record)
  File "%USERPROFILE%\github\flexget\lib\site-packages\loguru\_file_sink.py", line 175, in write
    self._initialize_file(rename_existing=True)
  File "%USERPROFILE%\github\flexget\lib\site-packages\loguru\_file_sink.py", line 189, in _initialize_file
    os.rename(new_path, renamed_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '%USERPROFILE%\\flexget\\flexget.log' -> '%USERPROFILE%\\flexget\\flexget.2019-12-28_19-13-58_544131.log'
--- End of logging error ---

Additional information:

Checked flexget.log with LockHunter to find the culprit for the file being in use, and all it returned was the pythonw.exe instance that's running Flexget

  • FlexGet version: 3.0.27
  • Python version: 3.7
  • Installation method: git \ virtualenv
  • Using daemon (yes/no): yes
  • OS and version: Win10
  • Link to crash log:

Activity

  1. gazpachoking commented on Dec 31, 2019

    @gazpachoking
    Member

    Hmm. Seems to be working on my end, does this happen all the time? Also, the filename you mentioned flexget.log.1-9 seems wierd. I get filenames like flexget.2019-12-30_20-16-14_394822.log

  2. BrutuZ commented on Dec 31, 2019

    @BrutuZ
    ContributorAuthor

    It happens consistently when the Daemon is running (regardless of flexget-headless.exe or flexget.exe), but the message pasted as Log only shows in the terminal window (the one I use to run flexget execute for this test), doesn't get written into the log files.

    The filename pattern seems to have changed with the migration to loguru, I thought it was related to this issue but was mistaken. I just preferred the "old" flexget.log.1, flexget.log.2...flexget.log.9 because it looked cleaner and my cloud sync knew to just ignore these filenames, but won't oppose to the timestamped files, just 9MB (at most!) is negligible and I can see them being useful during a ls :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions