topup / laralog
Log request & response including header, body etc...
Installs: 182
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 7
Forks: 0
Open Issues: 0
pkg:composer/topup/laralog
Requires
- php: >=7.2
- ext-json: *
- illuminate/support: ^6.0
This package is auto-updated.
Last update: 2026-01-18 12:44:30 UTC
README
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
- Install the package via composer
composer require topup/laralog
Usage
- (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.
- Migrate using the command bellow:
php artisan migrate
-
Use middleware
topup-loggerto any route that need to debug -
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);
- 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=
- Enjoy