A library with logging enhancement. Including:
LogWithClassPathtrait- It adds convinient methods for logging to add class path into context.
LogglyHandlerclass- It extends monolog's LogglyHandler with tags support
composer require onramplab/laravel-log-enhancementUse LogWithClassPath trait to let it automatically put class path into log context. You can refer to following code example.
namespace App; use Onramplab\LaravelLogEnhancement\Concerns\LogWithClassPath; class Fake { use LogWithClassPath; public function run() { $this->info('Test'); } }The log json will look like this:
{ "message": "Test", "context": { "class_path": "App\\Fake" }, "level": 200, "level_name": "INFO", "channel": "local", "extra": {}, "timestamp": "2021-01-04T22:47:56.598608-0800" }You can adding following block into config/logging.php.
use Monolog\Formatter\LogglyFormatter; use Onramplab\LaravelLogEnhancement\Handlers\LogglyHandler; return [ //... 'channels' => [ //... 'loggly' => [ 'driver' => 'monolog', 'level' => 'info', 'handler' => LogglyHandler::class, 'handler_with' => [ 'token' => env('LOGGLY_TOKEN'), 'tags' => env('LOGGLY_TAGS'), ], 'formatter' => LogglyFormatter::class, ], ] ];Run the tests with:
vendor/bin/phpunitPlease see CONTRIBUTING for details.
If you discover any security-related issues, please email kos.huang@onramplab.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.# laravel-log-enhancement