mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-17 05:06:28 +00:00
Add logger to FileCookieJar
This commit is contained in:
parent
9a80dcf11e
commit
51d7f62b31
2 changed files with 22 additions and 1 deletions
|
@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Helper;
|
||||||
use GuzzleHttp\Cookie\FileCookieJar as BaseFileCookieJar;
|
use GuzzleHttp\Cookie\FileCookieJar as BaseFileCookieJar;
|
||||||
use GuzzleHttp\Cookie\SetCookie;
|
use GuzzleHttp\Cookie\SetCookie;
|
||||||
use GuzzleHttp\Utils;
|
use GuzzleHttp\Utils;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overidden Cookie behavior to:
|
* Overidden Cookie behavior to:
|
||||||
|
@ -13,6 +14,19 @@ use GuzzleHttp\Utils;
|
||||||
*/
|
*/
|
||||||
class FileCookieJar extends BaseFileCookieJar
|
class FileCookieJar extends BaseFileCookieJar
|
||||||
{
|
{
|
||||||
|
private $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param LoggerInterface $logger Only used to log info when something goes wrong
|
||||||
|
* @param string $cookieFile File to store the cookie data
|
||||||
|
*/
|
||||||
|
public function __construct(LoggerInterface $logger, $cookieFile)
|
||||||
|
{
|
||||||
|
parent::__construct($cookieFile);
|
||||||
|
|
||||||
|
$this->logger = $logger;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the cookies to a file.
|
* Saves the cookies to a file.
|
||||||
*
|
*
|
||||||
|
@ -57,6 +71,11 @@ class FileCookieJar extends BaseFileCookieJar
|
||||||
try {
|
try {
|
||||||
$data = Utils::jsonDecode($json, true);
|
$data = Utils::jsonDecode($json, true);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
$this->logger->error('JSON inside the cookie is broken', [
|
||||||
|
'json' => $json,
|
||||||
|
'error_msg' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
|
||||||
// cookie file is invalid, just ignore the exception and it'll reset the whole cookie file
|
// cookie file is invalid, just ignore the exception and it'll reset the whole cookie file
|
||||||
$data = '';
|
$data = '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,9 @@ services:
|
||||||
|
|
||||||
wallabag_core.guzzle.cookie_jar:
|
wallabag_core.guzzle.cookie_jar:
|
||||||
class: Wallabag\CoreBundle\Helper\FileCookieJar
|
class: Wallabag\CoreBundle\Helper\FileCookieJar
|
||||||
arguments: ["%kernel.cache_dir%/cookiejar.json"]
|
arguments:
|
||||||
|
- "@logger"
|
||||||
|
- "%kernel.cache_dir%/cookiejar.json"
|
||||||
|
|
||||||
wallabag_core.content_proxy:
|
wallabag_core.content_proxy:
|
||||||
class: Wallabag\CoreBundle\Helper\ContentProxy
|
class: Wallabag\CoreBundle\Helper\ContentProxy
|
||||||
|
|
Loading…
Reference in a new issue