cryonighter/http-logger

Logger for HTTP request and response

1.0.1 2023-06-07 20:33 UTC

This package is not auto-updated.

Last update: 2024-12-19 04:34:47 UTC


README

Latest Version on Packagist Software License Total Downloads

This is a set of interfaces, the implementations of which are presented for example or are completely stubs.

Highlights

  • Simple API
  • Framework Agnostic
  • Composer ready, PSR-2 and PSR-4 compliant

System Requirements

You need:

  • PHP >= 7.2.0 but the latest stable version of PHP is recommended

Install

Via Composer

$ composer require cryonighter/http-logger

Usage

use Cryonighter\HttpLogger\StreamHttpLogger;
use Cryonighter\HttpLogger\Formatter\PlainTextFormatter;
use Cryonighter\HttpLogger\Handler\DefaultRequestHandler;
use Cryonighter\HttpLogger\Handler\DefaultResponseHandler;

$logger = new StreamHttpLogger(STDOUT, new PlainTextFormatter(), new DefaultRequestHandler(), new DefaultResponseHandler());

$logger->logRequest($protocolVersion, $method, $uri, $headers, $body);
$logger->logResponse($protocolVersion, $code, $reason, $headers, $body);

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ php vendor/phpunit/phpunit/phpunit tests

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email cryonighter@yandex.ru instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.