diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-07-24 16:07:38 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-07-24 16:07:38 +0200 |
commit | 51d7f62b316abfc14e770b3108edb0e3f48e38dd (patch) | |
tree | 9ceebc0956bdd03aa58e8267149cfbb585b04f8b /src/Wallabag/CoreBundle/Helper | |
parent | 9a80dcf11e4f3ee4f4a751550afc6469e76b22d9 (diff) | |
download | wallabag-51d7f62b316abfc14e770b3108edb0e3f48e38dd.tar.gz wallabag-51d7f62b316abfc14e770b3108edb0e3f48e38dd.tar.zst wallabag-51d7f62b316abfc14e770b3108edb0e3f48e38dd.zip |
Add logger to FileCookieJar
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/FileCookieJar.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/FileCookieJar.php b/src/Wallabag/CoreBundle/Helper/FileCookieJar.php index 52c7f5de..9a63e949 100644 --- a/src/Wallabag/CoreBundle/Helper/FileCookieJar.php +++ b/src/Wallabag/CoreBundle/Helper/FileCookieJar.php | |||
@@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Helper; | |||
5 | use GuzzleHttp\Cookie\FileCookieJar as BaseFileCookieJar; | 5 | use GuzzleHttp\Cookie\FileCookieJar as BaseFileCookieJar; |
6 | use GuzzleHttp\Cookie\SetCookie; | 6 | use GuzzleHttp\Cookie\SetCookie; |
7 | use GuzzleHttp\Utils; | 7 | use GuzzleHttp\Utils; |
8 | use Psr\Log\LoggerInterface; | ||
8 | 9 | ||
9 | /** | 10 | /** |
10 | * Overidden Cookie behavior to: | 11 | * Overidden Cookie behavior to: |
@@ -13,6 +14,19 @@ use GuzzleHttp\Utils; | |||
13 | */ | 14 | */ |
14 | class FileCookieJar extends BaseFileCookieJar | 15 | class FileCookieJar extends BaseFileCookieJar |
15 | { | 16 | { |
17 | private $logger; | ||
18 | |||
19 | /** | ||
20 | * @param LoggerInterface $logger Only used to log info when something goes wrong | ||
21 | * @param string $cookieFile File to store the cookie data | ||
22 | */ | ||
23 | public function __construct(LoggerInterface $logger, $cookieFile) | ||
24 | { | ||
25 | parent::__construct($cookieFile); | ||
26 | |||
27 | $this->logger = $logger; | ||
28 | } | ||
29 | |||
16 | /** | 30 | /** |
17 | * Saves the cookies to a file. | 31 | * Saves the cookies to a file. |
18 | * | 32 | * |
@@ -57,6 +71,11 @@ class FileCookieJar extends BaseFileCookieJar | |||
57 | try { | 71 | try { |
58 | $data = Utils::jsonDecode($json, true); | 72 | $data = Utils::jsonDecode($json, true); |
59 | } catch (\InvalidArgumentException $e) { | 73 | } catch (\InvalidArgumentException $e) { |
74 | $this->logger->error('JSON inside the cookie is broken', [ | ||
75 | 'json' => $json, | ||
76 | 'error_msg' => $e->getMessage(), | ||
77 | ]); | ||
78 | |||
60 | // cookie file is invalid, just ignore the exception and it'll reset the whole cookie file | 79 | // cookie file is invalid, just ignore the exception and it'll reset the whole cookie file |
61 | $data = ''; | 80 | $data = ''; |
62 | } | 81 | } |