<commit_before><?php

namespace Gmponos\GuzzleLogger\Middleware;

use Closure;
use Gmponos\GuzzleLogger\Handler\ArrayHandler;
use Gmponos\GuzzleLogger\Handler\HandlerInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\TransferStats;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;

/**
 * A class to log HTTP Requests and Responses of Guzzle.
 *
 * @author <NAME> <<EMAIL>>
 */
class LoggerMiddleware
{
    /**
     * Whether or not to log requests as they are made.
     *
     * @var bool
     */
    private $onExceptionOnly;

    /**
     * Whether or not to log statistics.
     *
     * @var bool
     */
    private $logStatistics;

    /**
     * @var HandlerInterface
     */
    private $handler;

    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * Creates a callable middleware for logging requests and responses.
     *
     * @param LoggerInterface $logger
     * @param HandlerInterface $handler
     * @param bool $onExceptionOnly The request and the response will be logged only in cases there is an exception or if they status code exceeds the thresholds.
     * @param bool $logStatistics If this is true an extra row will be added that will contain some HTTP statistics.
     */
    public function __construct(
        LoggerInterface $logger,
        HandlerInterface $handler = null,
        $onExceptionOnly = false,
        $logStatistics = false<commit_msg>Change middleware<commit_after><?php

namespace Gmponos\GuzzleLogger\Middleware;

use Closure;
use Gmponos\GuzzleLogger\Handler\ArrayHandler;
use Gmponos\GuzzleLogger\Handler\HandlerInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\TransferStats;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;

/**
 * A class to log HTTP Requests and Responses of Guzzle.
 *
 * @author <NAME> <<EMAIL>>
 */
class LoggerMiddleware
{
    /**
     * @var bool
     */
    private $onExceptionOnly;

    /**
     * Decides if you need to log statistics or not.
     *
     * @var bool
     */
    private $logStatistics;

    /**
     * @var HandlerInterface
     */
    private $handler;

    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * Creates a callable middleware for logging requests and responses.
     *
     * @param LoggerInterface $logger
     * @param HandlerInterface $handler
     * @param bool $onExceptionOnly The request and the response will be logged only in cases there is an exception or if they status code exceeds the thresholds.
     * @param bool $logStatistics If this is true an extra row will be added that will contain some HTTP statistics.
     */
    public function __construct(
        LoggerInterface $logger,
        HandlerInterface $handler = null,
        $onExceptionOnly = false,
        $logStatistics = false
{'fraction_non_alphanumeric': 0.08427157966564312, 'fraction_numerical': 0.0, 'mean_word_length': 2.898936170212766, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2630438', 'n_tokens_mistral': 832, 'n_tokens_neox': 801, 'n_words': 269}