artmoi / laravel-datadog
A better Dogstatsd integration with Laravel.
Installs: 11 181
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 4
Forks: 4
Open Issues: 1
Requires
- datadog/php-datadogstatsd: ^1.0
- laravel/framework: ^5.6
- myclabs/php-enum: ^1.6
- ramsey/uuid: ^3.8
This package is auto-updated.
Last update: 2022-02-01 13:54:52 UTC
README
Everything you want for datadog logging in Laravel under a single package.
Configuring
Add the following to config/logging.php
in your project:
// ... 'datadog' => [ // You can provdie any key/value pairs normally accepted by `\DataDog\DogStatsD::__construct()` at this level. 'app_key' => env('DATADOG_APP_KEY'), 'api_key' => env('DATADOG_API_KEY'), // Optional: Minimum monolog logging level. If left unconfigured, it will self-configure based on `app.debug` // 'level' => Logger::DEBUG, // Optional: Tags to include when sending events to datadog. // 'tags' => [ // ], ], 'channels' => [ // Add a new monolog-based channel using the handler from this package. 'datadog' => [ 'driver' => 'monolog', 'handler' => \ArtMoi\LaravelDatadog\DatadogMonologHandler::class, 'formatter' => 'default', ], // ...
Usage
After configuring the logger, any application logs should be automatically sent to datadog.
If you wish to trigger your own events via DogStatsD
, simply request the type for dependency injection.
Meta
There are two libraries already out there for logging in either laravel or with monolog. This library combines the advantages of both while following a more composable architecture:
- Laravel package auto discovery.
- Monolog handler does not internally construct the type
\DataDog\DogStatsd
.