diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2020-10-04 18:17:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-04 18:17:40 +0300 |
commit | c8c2eb099d6209a66f626748f83cf6fe16ba6db4 (patch) | |
tree | 0210c80befe47ed274a808bfcf984cd253c2e3c9 /lib | |
parent | 676175bf9fb458bdc5f434451403f6bbd1c0747a (diff) | |
parent | 664dcc975dc867af3171faed9e5bba5fb30d5929 (diff) |
Merge pull request #3717 from nextcloud/techdept/imap-logger-interface
Migrate \OCA\Mail\IMAP\* to the logger interface
Diffstat (limited to 'lib')
-rw-r--r-- | lib/IMAP/MessageMapper.php | 28 | ||||
-rw-r--r-- | lib/IMAP/PreviewEnhancer.php | 11 | ||||
-rw-r--r-- | lib/IMAP/Search/Provider.php | 8 |
3 files changed, 18 insertions, 29 deletions
diff --git a/lib/IMAP/MessageMapper.php b/lib/IMAP/MessageMapper.php index 3b4fde341..2abfdad40 100644 --- a/lib/IMAP/MessageMapper.php +++ b/lib/IMAP/MessageMapper.php @@ -36,7 +36,7 @@ use OCA\Mail\Db\Mailbox; use OCA\Mail\Exception\ServiceException; use OCA\Mail\Model\IMAPMessage; use OCP\AppFramework\Db\DoesNotExistException; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use function array_filter; use function array_map; use function iterator_to_array; @@ -44,10 +44,10 @@ use function reset; class MessageMapper { - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; - public function __construct(ILogger $logger) { + public function __construct(LoggerInterface $logger) { $this->logger = $logger; } @@ -252,9 +252,10 @@ class MessageMapper { 'move' => true, ]); } catch (Horde_Imap_Client_Exception $e) { - $this->logger->logException( - $e, - ['level' => ILogger::DEBUG] + $this->logger->debug($e->getMessage(), + [ + 'exception' => $e, + ] ); throw new ServiceException( @@ -288,21 +289,16 @@ class MessageMapper { 'delete' => true, ]); } catch (Horde_Imap_Client_Exception $e) { - $this->logger->logException( - $e, - ['level' => ILogger::DEBUG] + $this->logger->debug($e->getMessage(), + [ + 'exception' => $e, + ] ); throw new ServiceException("Could not expunge message $id", 0, $e); } - $this->logger->info( - "Message expunged: {message} from mailbox {mailbox}", - [ - 'message' => $id, - 'mailbox' => $mailbox, - ] - ); + $this->logger->info("Message expunged: $id from mailbox $mailbox"); } /** diff --git a/lib/IMAP/PreviewEnhancer.php b/lib/IMAP/PreviewEnhancer.php index f7fc5472d..1f20bdf32 100644 --- a/lib/IMAP/PreviewEnhancer.php +++ b/lib/IMAP/PreviewEnhancer.php @@ -31,7 +31,7 @@ use OCA\Mail\Db\Mailbox; use OCA\Mail\Db\Message; use OCA\Mail\Db\MessageMapper as DbMapper; use OCA\Mail\IMAP\MessageMapper as ImapMapper; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use function array_key_exists; use function array_map; use function array_merge; @@ -48,13 +48,13 @@ class PreviewEnhancer { /** @var DbMapper */ private $mapper; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(IMAPClientFactory $clientFactory, ImapMapper $imapMapper, DbMapper $dbMapper, - ILogger $logger) { + LoggerInterface $logger) { $this->clientFactory = $clientFactory; $this->imapMapper = $imapMapper; $this->mapper = $dbMapper; @@ -89,9 +89,8 @@ class PreviewEnhancer { ); } catch (Horde_Imap_Client_Exception $e) { // Ignore for now, but log - $this->logger->logException($e, [ - 'message' => 'Could not fetch structure detail data to enhance message previews', - 'level' => ILogger::WARN, + $this->logger->warning('Could not fetch structure detail data to enhance message previews: ' . $e->getMessage(), [ + 'exception' => $e, ]); return $messages; diff --git a/lib/IMAP/Search/Provider.php b/lib/IMAP/Search/Provider.php index 57f53c748..8f168f211 100644 --- a/lib/IMAP/Search/Provider.php +++ b/lib/IMAP/Search/Provider.php @@ -32,7 +32,6 @@ use OCA\Mail\Db\Mailbox; use OCA\Mail\Exception\ServiceException; use OCA\Mail\IMAP\IMAPClientFactory; use OCA\Mail\Service\Search\SearchQuery; -use OCP\ILogger; use function array_reduce; class Provider { @@ -40,13 +39,8 @@ class Provider { /** @var IMAPClientFactory */ private $clientFactory; - /** @var ILogger */ - private $logger; - - public function __construct(IMAPClientFactory $clientFactory, - ILogger $logger) { + public function __construct(IMAPClientFactory $clientFactory) { $this->clientFactory = $clientFactory; - $this->logger = $logger; } /** |