Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Oras Al-Kubaisi committed May 3, 2017
2 parents 0c1b09a + 74c600f commit 1e2dd79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"php": "^5.5 || ^7.0",
"monolog/monolog": "^1.19",
"psr/http-message": "~1.0.0",
"zendframework/zend-stratigility": "^1.2",
"zendframework/zend-stratigility": "^2",
"container-interop/container-interop": "^1.1",
"symfony/http-foundation": "^3.0",
"guzzlehttp/psr7": "^1.3 || ^1.4"
Expand Down
21 changes: 8 additions & 13 deletions src/MonologMiddleware/MonologMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace MonologMiddleware;

use Interop\Http\ServerMiddleware\DelegateInterface;
use Interop\Http\ServerMiddleware\MiddlewareInterface;
use Monolog\Logger;
use MonologMiddleware\Loggable\LoggableData;
use MonologMiddleware\Loggable\LoggableProvider;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\HttpFoundation\Response;
use Zend\Stratigility\MiddlewareInterface;

/**
* Class MonologMiddleware
Expand Down Expand Up @@ -36,21 +37,14 @@ public function __construct(Logger $logger, loggableProvider $loggableProvider)
$this->loggableProvider = $loggableProvider;
}


/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable $next
* @return mixed
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
$nextResponse = $next($request, $response);
$response = $delegate->process($request);
$level = $this->getLogLevel($response->getStatusCode());

$this->log($level, $request, $nextResponse);
$this->log($level, $request, $response);

return $nextResponse;
return $response;
}

/**
Expand Down Expand Up @@ -83,10 +77,11 @@ public function getLogLevel($responseCode)
return $level;
}


/**
* @param $level
* @param ServerRequestInterface $request
* @param Response $response
* @param ResponseInterface $response
* @return bool
*/
public function log($level, ServerRequestInterface $request, ResponseInterface $response)
Expand Down

0 comments on commit 1e2dd79

Please sign in to comment.