dejwcake / advanced-logger
Advanced logger
Installs: 6 854
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 13
Type:project
pkg:composer/dejwcake/advanced-logger
Requires
- php: ^8.2
- ext-json: *
- illuminate/http: ^10.0 || ^11.0 || ^12.0
- illuminate/support: ^10.0 || ^11.0 || ^12.0
- monolog/monolog: ^3.0
Requires (Dev)
- larastan/larastan: ^3.1
- laravel/framework: ^10.0 || ^11.0 || ^12.0
- orchestra/testbench: ^10.0
- phpunit/phpunit: ^11.5.9
README
Advanced Logger is a Laravel package that automatically logs every HTTP request made to your Laravel application. Each request is assigned a unique hash, which can also be included in your standard logs to easily match log entries to a specific request.
This package is inspired by https://github.com/andersao/laravel-request-logger by Anderson Andrade.
Installation
Composer
Run composer require dejwcake/advanced-logger in your terminal.
Laravel
This package is for Laravel 10, 11 or 12.
To publish config file, run
php artisan vendor:publish --provider="Brackets\AdvancedLogger\AdvancedLoggerServiceProvider"
Configuration
All options are described in config/advanced-logger.php.
Using request hash in standard log file
If you would like to include the request identifier in your standard log so you can match log events to a specific request, add the following to config/logging.php:
'tap' => [Brackets\AdvancedLogger\LogCustomizers\HashLogCustomizer::class],
to daily channel. The resulted code should looks like
'channels' => [ ... 'daily' => [ 'driver' => 'daily', 'path' => storage_path('logs/laravel.log'), 'level' => 'debug', 'days' => 14, 'tap' => [Brackets\AdvancedLogger\LogCustomizers\HashLogCustomizer::class], ], ... ],
This log modifier can also be applied to other logging channels. However, it relies on an extended LineFormatter, so make sure the target channel is compatible with that formatter.
How to develop this project
Composer
Update dependencies:
docker compose run -it --rm test composer update
Composer normalization:
docker compose run -it --rm php-qa composer normalize
Run tests
Run tests with pcov:
docker compose run -it --rm test ./vendor/bin/phpunit -d pcov.enabled=1
To switch between postgresql and mariadb change in docker-compose.yml DB_CONNECTION environmental variable:
- DB_CONNECTION: pgsql
+ DB_CONNECTION: mysql
Run code analysis tools (php-qa)
PHP compatibility:
docker compose run -it --rm php-qa phpcs --standard=.phpcs.compatibility.xml --cache=.phpcs.cache
Code style:
docker compose run -it --rm php-qa phpcs -s --colors --extensions=php
Fix style issues:
docker compose run -it --rm php-qa phpcbf -s --colors --extensions=php
Static analysis (phpstan):
docker compose run -it --rm php-qa phpstan analyse --configuration=phpstan.neon
Mess detector (phpmd):
docker compose run -it --rm php-qa phpmd ./src,./config,./tests ansi phpmd.xml --suffixes php --baseline-file phpmd.baseline.xml