Created
May 10, 2013 09:22
-
-
Save gunnarlium/5553418 to your computer and use it in GitHub Desktop.
Guzzle\Log\MessageFormatter issue. Check output in guzzle.log.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"guzzle/guzzle": "3.4.1", | |
"monolog/monolog": "~1.5" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use Guzzle\Http\Client; | |
use Guzzle\Plugin\Log\LogPlugin; | |
use Guzzle\Log\MessageFormatter; | |
use Guzzle\Log\MonologLogAdapter; | |
$client = new CLient('http://en.wikipedia.org'); | |
use Monolog\Logger; | |
use Monolog\Handler\StreamHandler; | |
$logger = new Logger('guzzle'); | |
$logger->pushHandler(new StreamHandler('guzzle.log', Logger::DEBUG)); | |
$logAdapter = new MonologLogAdapter($logger); | |
$logFormatter = new MessageFormatter('{code} {method} {url} in {total_time}s'); | |
$logPlugin = new LogPlugin($logAdapter, $logFormatter); | |
$client->addSubscriber($logPlugin); | |
$request = $client->get('wiki/Guzzle'); | |
$response = $request->send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment