Download the PHP package understand/understand-lumen without Composer
On this page you can find all versions of the php package understand/understand-lumen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download understand/understand-lumen
More information about understand/understand-lumen
Files in understand/understand-lumen
Package understand-lumen
Short Description Understand.io Laravel Lumen service provider.
License MIT
Homepage https://github.com/understand/understand-lumen
Informations about the package understand-lumen
The service provider is deprecated - it does not support error grouping.
Laravel Lumen service provider for Understand.io
You may also be interested in our Laravel 4, Laravel 5 service provider or Monolog Understand.io handler
Introduction
This packages provides a full abstraction for Understand.io and provides extra features to improve Lumen's default logging capabilities. It is essentially a wrapper around our Understand Monolog handler to take full advantage of Understand.io's data aggregation and analysis capabilities.
Quick start
-
Add this package to your project via composer:
-
In
bootstrap/app.php
enableDotenv
(around line 5) AND$app->withFacades();
(around line 22): -
In
bootstrap/app.php
register the UnderstandLumenServiceProvider: -
Create a new file as
config/understand_lumen.php
(note that you may need to create theconfig
directory) with the following contents: -
Set your input key (from Understand.io) in your
.env
file asUNDERSTAND_INPUT_KEY
-
Open
app/Exceptions/Handler.php
and adjust thereport
method: - Send your first event
Additional meta data (field providers)
You may wish to capture additional meta data with each event. For example, it can be very useful to capture the request url with exceptions, or perhaps you want to capture the current user's ID. To do this, you can specify custom field providers via the config.
The Understand.io service provider contains a powerful field provider class which provides default providers, and you can create or extend new providers.
Default field providers
The following field providers are included in this package:
getSessionId
- return sha1 version of session idgetUrl
- return current url (e.g./my/path?with=querystring
).getRequestMethod
- return request method (e.g.POST
).getServerIp
- return server IP.getClientIp
- return client IP.getClientUserAgent
- return client's user agent.getEnvironment
- return Lumen environment (e.g.production
).getProcessIdentifier
- return unique token which is unique for every request. This allows you to easily group all events which happen in a single request.getUserId
- return current user id. This is only available if you make sure of the default Laravel Lumen auth or the cartalyst/sentry package. Alternatively, if you make use of a different auth package, then you can extend thegetUserId
field provider and implement your own logic.
How to extend create your own methods or extend the field providers
Example
Lets assume that you have defined a custom field provider called getMyCustomValue
(as above). You should then add this to your config file as follows:
This additional meta data will then be automatically appended to all of your Lumen log events (Log::info('my_custom_event')
), and will appear as follows:
How to send data asynchronously
Async handler
By default each log event will be sent to Understand.io's api server directly after the event happens. If you generate a large number of logs, this could slow your app down and, in these scenarios, we recommend that you make use of a async handler. To do this, change the config parameter handler
to async
.
The async handler is supported in most of the systems - the only requirement is that CURL command line tool is installed and functioning correctly. To check whether CURL is available on your system, execute following command in your console:
If you see instructions on how to use CURL then your system has the CURL binary installed and you can use the handler.
Keep in mind that Lumen allows you to specify different configuration values in different environments. You could, for example, use the async handler in production and the sync handler in development.
Configuration
Requirements
UTF-8
This package uses the json_encode function, which only supports UTF-8 data, and you should therefore ensure that all of your data is correctly encoded. In the event that your log data contains non UTF-8 strings, then the json_encode function will not be able to serialize the data.
http://php.net/manual/en/function.json-encode.php
License
The Laravel Lumen Understand.io service provider is open-sourced software licensed under the MIT license