From c44fe85abc2bc39d7d6fdd14d2189b120e6a4190 Mon Sep 17 00:00:00 2001 From: abdulmohsen Date: Tue, 6 Sep 2022 17:32:01 +0300 Subject: [PATCH] Improved logging when encountering unexpected content type. Update #239 --- src/Backends/Emby/Action/ParseWebhook.php | 2 +- src/Backends/Jellyfin/Action/Backup.php | 4 ++-- src/Backends/Jellyfin/Action/Export.php | 6 +++--- src/Backends/Jellyfin/Action/Import.php | 4 ++-- src/Backends/Jellyfin/Action/ParseWebhook.php | 2 +- src/Backends/Jellyfin/JellyfinActionTrait.php | 2 +- src/Backends/Plex/Action/Backup.php | 4 ++-- src/Backends/Plex/Action/Export.php | 6 +++--- src/Backends/Plex/Action/Import.php | 4 ++-- src/Backends/Plex/Action/ParseWebhook.php | 2 +- src/Backends/Plex/PlexActionTrait.php | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Backends/Emby/Action/ParseWebhook.php b/src/Backends/Emby/Action/ParseWebhook.php index 5f65acbe..e0ae02ef 100644 --- a/src/Backends/Emby/Action/ParseWebhook.php +++ b/src/Backends/Emby/Action/ParseWebhook.php @@ -137,7 +137,7 @@ final class ParseWebhook ) ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ), diff --git a/src/Backends/Jellyfin/Action/Backup.php b/src/Backends/Jellyfin/Action/Backup.php index a1f63b96..1ea329a4 100644 --- a/src/Backends/Jellyfin/Action/Backup.php +++ b/src/Backends/Jellyfin/Action/Backup.php @@ -35,7 +35,7 @@ class Backup extends Import try { if ($context->trace) { - $this->logger->debug('Processing [%(backend)] %(item.type) payload.', [ + $this->logger->debug('Processing [%(backend)] payload.', [ 'backend' => $context->backendName, ...$logContext, 'payload' => $item, @@ -60,7 +60,7 @@ class Backup extends Import ) ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ), diff --git a/src/Backends/Jellyfin/Action/Export.php b/src/Backends/Jellyfin/Action/Export.php index c48e0d4f..4e54eb1c 100644 --- a/src/Backends/Jellyfin/Action/Export.php +++ b/src/Backends/Jellyfin/Action/Export.php @@ -35,13 +35,13 @@ class Export extends Import try { if ($context->trace) { - $this->logger->debug('Processing [%(backend)] %(item.type) payload.', [ + $this->logger->debug('Processing [%(backend)] payload.', [ 'backend' => $context->backendName, ...$logContext, 'body' => $item, ]); } - + $queue = ag($opts, 'queue', fn() => Container::get(QueueRequests::class)); $after = ag($opts, 'after', null); @@ -64,7 +64,7 @@ class Export extends Import ) ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ), diff --git a/src/Backends/Jellyfin/Action/Import.php b/src/Backends/Jellyfin/Action/Import.php index c59f7093..d444e43c 100644 --- a/src/Backends/Jellyfin/Action/Import.php +++ b/src/Backends/Jellyfin/Action/Import.php @@ -707,7 +707,7 @@ class Import try { if ($context->trace) { - $this->logger->debug('Processing [%(backend)] %(item.type) payload.', [ + $this->logger->debug('Processing [%(backend)] payload.', [ 'backend' => $context->backendName, ...$logContext, 'body' => $item @@ -734,7 +734,7 @@ class Import ) ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ), diff --git a/src/Backends/Jellyfin/Action/ParseWebhook.php b/src/Backends/Jellyfin/Action/ParseWebhook.php index 0c9a9c12..46439fc0 100644 --- a/src/Backends/Jellyfin/Action/ParseWebhook.php +++ b/src/Backends/Jellyfin/Action/ParseWebhook.php @@ -115,7 +115,7 @@ final class ParseWebhook ) ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ), diff --git a/src/Backends/Jellyfin/JellyfinActionTrait.php b/src/Backends/Jellyfin/JellyfinActionTrait.php index 022233fd..9fd8c026 100644 --- a/src/Backends/Jellyfin/JellyfinActionTrait.php +++ b/src/Backends/Jellyfin/JellyfinActionTrait.php @@ -62,7 +62,7 @@ trait JellyfinActionTrait str_pad((string)ag($item, 'IndexNumber', 0), 3, '0', STR_PAD_LEFT), ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ), diff --git a/src/Backends/Plex/Action/Backup.php b/src/Backends/Plex/Action/Backup.php index d0e02bcd..5cf22f41 100644 --- a/src/Backends/Plex/Action/Backup.php +++ b/src/Backends/Plex/Action/Backup.php @@ -35,7 +35,7 @@ final class Backup extends Import try { if ($context->trace) { - $this->logger->debug('Processing [%(backend)] %(item.type) payload.', [ + $this->logger->debug('Processing [%(backend)] payload.', [ 'backend' => $context->backendName, ...$logContext, 'payload' => $item, @@ -63,7 +63,7 @@ final class Backup extends Import str_pad((string)ag($item, 'index', 0), 3, '0', STR_PAD_LEFT), ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ), diff --git a/src/Backends/Plex/Action/Export.php b/src/Backends/Plex/Action/Export.php index c58b2de2..1955009d 100644 --- a/src/Backends/Plex/Action/Export.php +++ b/src/Backends/Plex/Action/Export.php @@ -40,13 +40,13 @@ final class Export extends Import try { if ($context->trace) { - $this->logger->debug('Processing [%(backend)] %(item.type) payload.', [ + $this->logger->debug('Processing [%(backend)] payload.', [ 'backend' => $context->backendName, ...$logContext, 'body' => $item, ]); } - + Message::increment("{$context->backendName}.{$library}.total"); Message::increment("{$context->backendName}.{$mappedType}.total"); @@ -70,7 +70,7 @@ final class Export extends Import str_pad((string)ag($item, 'index', 0), 3, '0', STR_PAD_LEFT), ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ), diff --git a/src/Backends/Plex/Action/Import.php b/src/Backends/Plex/Action/Import.php index a1e15a51..ed216379 100644 --- a/src/Backends/Plex/Action/Import.php +++ b/src/Backends/Plex/Action/Import.php @@ -718,7 +718,7 @@ class Import try { if ($context->trace) { - $this->logger->debug('Processing [%(backend)] %(item.type) [%(item.title)] payload.', [ + $this->logger->debug('Processing [%(backend)] payload.', [ 'backend' => $context->backendName, ...$logContext, 'body' => $item, @@ -748,7 +748,7 @@ class Import str_pad((string)ag($item, 'index', 0), 3, '0', STR_PAD_LEFT), ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ), diff --git a/src/Backends/Plex/Action/ParseWebhook.php b/src/Backends/Plex/Action/ParseWebhook.php index 4f7a614b..74b73946 100644 --- a/src/Backends/Plex/Action/ParseWebhook.php +++ b/src/Backends/Plex/Action/ParseWebhook.php @@ -134,7 +134,7 @@ final class ParseWebhook str_pad((string)ag($item, 'index', 0), 3, '0', STR_PAD_LEFT), ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ), diff --git a/src/Backends/Plex/PlexActionTrait.php b/src/Backends/Plex/PlexActionTrait.php index b5359b9c..fdfd2588 100644 --- a/src/Backends/Plex/PlexActionTrait.php +++ b/src/Backends/Plex/PlexActionTrait.php @@ -80,7 +80,7 @@ trait PlexActionTrait str_pad((string)ag($item, 'index', 0), 3, '0', STR_PAD_LEFT), ), default => throw new InvalidArgumentException( - r('Invalid Content type [{type}] was given.', [ + r('Unexpected Content type [{type}] was received.', [ 'type' => $type ]) ),