Skip to content

Cleaner log rotation #1344

@wtgee

Description

@wtgee

Currently when we have a log rotation we get the following error message displayed in the main pocs run auto screen. This should be handled better so it doesn't appear there is an error with the unit.

--- Logging error in Loguru Handler #3 ---
Record was: {'elapsed': datetime.timedelta(days=1, seconds=1813, microseconds=232088), 'exception': None, 'extra': {'padding': '                   '}, 'file': (name='client.py', path='/home/panoptes/conda/envs/conda-pocs/lib/python3.12/site-packages/panoptes/utils/config/client.py'), 'function': 'get_config', 'level': (name='TRACE', no=5, icon='✏️ '), 'line': 108, 'message': "Calling get_config on url='http://localhost:6563/get-config' with  key='pocs.INTERRUPTED'", 'module': 'client', 'name': 'panoptes.utils.config.client', 'process': (id=2935, name='MainProcess'), 'thread': (id=281473397828352, name='MainThread'), 'time': datetime(2025, 8, 4, 11, 31, 8, 928399, tzinfo=datetime.timezone(datetime.timedelta(seconds=21600), '+06'))}
Traceback (most recent call last):
  File "/home/panoptes/conda/envs/conda-pocs/lib/python3.12/site-packages/loguru/_handler.py", line 315, in _queued_writer
    self._sink.write(message)
  File "/home/panoptes/conda/envs/conda-pocs/lib/python3.12/site-packages/loguru/_file_sink.py", line 204, in write
    self._terminate_file(is_rotating=True)
  File "/home/panoptes/conda/envs/conda-pocs/lib/python3.12/site-packages/loguru/_file_sink.py", line 281, in _terminate_file
    self._compression_function(old_path)
  File "/home/panoptes/conda/envs/conda-pocs/lib/python3.12/site-packages/loguru/_file_sink.py", line 66, in compression
    compress_function(path_in, path_out)
  File "/home/panoptes/conda/envs/conda-pocs/lib/python3.12/site-packages/loguru/_file_sink.py", line 53, in copy_compress
    with open(path_in, "rb") as f_in:
         ^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/panoptes/logs/panoptes_20250803.log'
--- End of logging error ---

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions