mirror of
https://github.com/ep1cman/unifi-protect-backup.git
synced 2025-12-05 23:53:30 +00:00
Reclassify log messages
This commit is contained in:
@@ -111,7 +111,7 @@ class VideoDownloader:
|
||||
self.current_event = None
|
||||
|
||||
except Exception as e:
|
||||
self.logger.warn(f"Unexpected exception occurred, abandoning event {event.id}:", exc_info=e)
|
||||
self.logger.error(f"Unexpected exception occurred, abandoning event {event.id}:", exc_info=e)
|
||||
|
||||
async def _download(self, event: Event) -> bytes:
|
||||
"""Downloads the video clip for the given event"""
|
||||
@@ -122,10 +122,10 @@ class VideoDownloader:
|
||||
assert isinstance(video, bytes)
|
||||
break
|
||||
except (AssertionError, ClientPayloadError, TimeoutError) as e:
|
||||
self.logger.warn(f" Failed download attempt {x+1}, retying in 1s", exc_info=e)
|
||||
self.logger.warning(f" Failed download attempt {x+1}, retying in 1s", exc_info=e)
|
||||
await asyncio.sleep(1)
|
||||
else:
|
||||
self.logger.warn(f"Download failed after 5 attempts, abandoning event {event.id}:")
|
||||
self.logger.error(f"Download failed after 5 attempts, abandoning event {event.id}:")
|
||||
return
|
||||
|
||||
self.logger.debug(f" Downloaded video size: {human_readable_size(len(video))}s")
|
||||
@@ -143,4 +143,4 @@ class VideoDownloader:
|
||||
else:
|
||||
self.logger.debug(msg)
|
||||
except SubprocessException as e:
|
||||
self.logger.warn(" `ffprobe` failed")
|
||||
self.logger.warning(" `ffprobe` failed")
|
||||
|
||||
@@ -91,14 +91,14 @@ class EventListener:
|
||||
if self._protect.check_ws():
|
||||
logger.extra_debug("Websocket is connected.")
|
||||
else:
|
||||
logger.warn("Lost connection to Unifi Protect.")
|
||||
logger.warning("Lost connection to Unifi Protect.")
|
||||
|
||||
# Unsubscribe, close the session.
|
||||
self._unsub()
|
||||
await self._protect.close_session()
|
||||
|
||||
while True:
|
||||
logger.warn("Attempting reconnect...")
|
||||
logger.warning("Attempting reconnect...")
|
||||
|
||||
try:
|
||||
# Start the pyunifiprotect connection by calling `update`
|
||||
@@ -109,9 +109,9 @@ class EventListener:
|
||||
self._unsub = self._protect.subscribe_websocket(self._websocket_callback)
|
||||
break
|
||||
else:
|
||||
logger.warn("Unable to establish connection to Unifi Protect")
|
||||
logger.error("Unable to establish connection to Unifi Protect")
|
||||
except Exception as e:
|
||||
logger.warn("Unexpected exception occurred while trying to reconnect:", exc_info=e)
|
||||
logger.error("Unexpected exception occurred while trying to reconnect:", exc_info=e)
|
||||
|
||||
# Back off for a little while
|
||||
await asyncio.sleep(10)
|
||||
|
||||
@@ -112,6 +112,6 @@ class MissingEventChecker:
|
||||
await self._download_queue.put(event)
|
||||
|
||||
except Exception as e:
|
||||
logger.warn(f"Unexpected exception occurred during missing event check:", exc_info=e)
|
||||
logger.error(f"Unexpected exception occurred during missing event check:", exc_info=e)
|
||||
|
||||
await asyncio.sleep(self.interval)
|
||||
|
||||
@@ -14,13 +14,13 @@ logger = logging.getLogger(__name__)
|
||||
async def delete_file(file_path):
|
||||
returncode, stdout, stderr = await run_command(f'rclone delete -vv "{file_path}"')
|
||||
if returncode != 0:
|
||||
logger.warn(f" Failed to delete file: '{file_path}'")
|
||||
logger.error(f" Failed to delete file: '{file_path}'")
|
||||
|
||||
|
||||
async def tidy_empty_dirs(base_dir_path):
|
||||
returncode, stdout, stderr = await run_command(f'rclone rmdirs -vv --ignore-errors --leave-root "{base_dir_path}"')
|
||||
if returncode != 0:
|
||||
logger.warn(f" Failed to tidy empty dirs")
|
||||
logger.error(f" Failed to tidy empty dirs")
|
||||
|
||||
|
||||
class Purge:
|
||||
@@ -69,7 +69,7 @@ class Purge:
|
||||
await tidy_empty_dirs(self.rclone_destination)
|
||||
|
||||
except Exception as e:
|
||||
logger.warn(f"Unexpected exception occurred during purge:", exc_info=e)
|
||||
logger.error(f"Unexpected exception occurred during purge:", exc_info=e)
|
||||
|
||||
next_purge_time = datetime.now() + self.interval
|
||||
logger.extra_debug(f'sleeping until {next_purge_time}')
|
||||
|
||||
@@ -68,7 +68,7 @@ class VideoUploader:
|
||||
self.current_event = None
|
||||
|
||||
except Exception as e:
|
||||
self.logger.warn(f"Unexpected exception occurred, abandoning event {event.id}:", exc_info=e)
|
||||
self.logger.error(f"Unexpected exception occurred, abandoning event {event.id}:", exc_info=e)
|
||||
|
||||
async def _upload_video(self, video: bytes, destination: pathlib.Path, rclone_args: str):
|
||||
"""Upload video using rclone.
|
||||
@@ -86,7 +86,7 @@ class VideoUploader:
|
||||
"""
|
||||
returncode, stdout, stderr = await run_command(f'rclone rcat -vv {rclone_args} "{destination}"', video)
|
||||
if returncode != 0:
|
||||
self.logger.warn(f" Failed to upload file: '{destination}'")
|
||||
self.logger.error(f" Failed to upload file: '{destination}'")
|
||||
|
||||
async def _update_database(self, event: Event, destination: str):
|
||||
"""
|
||||
|
||||
@@ -335,9 +335,9 @@ async def run_command(cmd: str, data=None):
|
||||
stderr_indented = '\t' + stderr.replace('\n', '\n\t').strip()
|
||||
|
||||
if proc.returncode != 0:
|
||||
logger.warn(f"Failed to run: '{cmd}")
|
||||
logger.warn(f"stdout:\n{stdout_indented}")
|
||||
logger.warn(f"stderr:\n{stderr_indented}")
|
||||
logger.error(f"Failed to run: '{cmd}")
|
||||
logger.error(f"stdout:\n{stdout_indented}")
|
||||
logger.error(f"stderr:\n{stderr_indented}")
|
||||
else:
|
||||
logger.extra_debug(f"stdout:\n{stdout_indented}")
|
||||
logger.extra_debug(f"stderr:\n{stderr_indented}")
|
||||
|
||||
Reference in New Issue
Block a user