8000 GitHub - topupLtd/laralog: Laravel: Log request & response including header, body & API call using guzzlehttp etc...
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

topupLtd/laralog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Topup Logger

A tiny package to debug request & response. It will log request & response header, user IP, time took to process the request & sending response. If a logged in user make the request it will log the user ID too.

Installation

  1. Install the package via composer
composer require topup/laralog

Usage

  1. (Optional) Set environment variables to use your own custom layout
TOPUP_LOGGER_LAYOUT="topup-logger::app"
TOPUP_LOGGER_CONTENT_SECTION=content

Both env value will fall back to package default value.

  1. Migrate using the command bellow:
php artisan migrate
  1. Use middleware topup-logger to any route that need to debug

  2. Log outbound request with guzzle http

use GuzzleHttp\Client;
use Topup\Logger\Http\Middleware\TopupGuzzleLoggerMiddleware;

$logger = new TopupGuzzleLoggerMiddleware();
$handlerStack = HandlerStack::create();
$handlerStack->setHandler(new CurlHandler());
$handlerStack->push($logger->log());

$client = new Client(['handler' => $handlerStack]);

Or

$history = Middleware::history($this->_guzzleReqResContainer);
$this->_handlerStack = HandlerStack::create();
$this->_handlerStack->push($history);

$client = new Client(['handler' => $handlerStack]);

(new LoggerController())->saveLog($this->_guzzleReqResContainer);
  1. Apply middlewares for package routes via .env
TOPUP_LOGGER_ROUTE_MIDDLEWARE=web,auth,admin

Separate multiple middlewares with a comma(,) i.e. auth,admin

Default will fallback to web

Empty is allowed if you intend not to use any middleware

TOPUP_LOGGER_ROUTE_MIDDLEWARE=
  1. Enjoy

About

Laravel: Log request & response including header, body & API call using guzzlehttp etc...

Resources

Stars

Watchers

Forks

Packages

No packages published
0