Skip to content

Commit 160ee98

Browse files
committed
Merge branch 'master' of github.com:understand/understand-laravel
2 parents 7f361b3 + 2cbc950 commit 160ee98

File tree

3 files changed

+54
-13
lines changed

3 files changed

+54
-13
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- hhvm
8+
9+
before_script:
10+
- travis_retry composer self-update
11+
- travis_retry composer install --prefer-source --no-interaction --dev
12+
13+
script: vendor/bin/phpunit --verbose

README.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,76 @@
11
## Laravel service provider for Understand.io
22

3+
[![Build Status](https://travis-ci.org/understand/understand-laravel.svg)](https://travis-ci.org/understand/understand-laravel)
4+
[![Latest Stable Version](https://poser.pugx.org/understand/understand-laravel/v/stable.svg)](https://packagist.org/packages/understand/understand-laravel)
5+
[![Latest Unstable Version](https://poser.pugx.org/understand/understand-laravel/v/unstable.svg)](https://packagist.org/packages/understand/understand-laravel)
6+
[![License](https://poser.pugx.org/understand/understand-laravel/license.svg)](https://packagist.org/packages/understand/understand-laravel)
7+
38
### Introduction
49

510
This packages provides a full abstraction for Understand.io and provides extra features to improve Laravel's default logging capabilities. It is essentially a wrapper around Laravel's event handler to take full advantage of Understand.io's data aggregation and analysis capabilities.
611

712
### Quick start
813

9-
1. Add this package to your composer.json and run `composer update`:
14+
1. Add this package to your composer.json
1015

1116
```php
12-
"understand/understand-laravel": "1.*"
17+
"understand/understand-laravel": "0.0.*"
18+
```
19+
20+
2. Update composer.json packages
21+
22+
```
23+
composer update
1324
```
1425

15-
2. Add the ServiceProvider to the providers array in app/config/app.php
26+
3. Add the ServiceProvider to the providers array in app/config/app.php
1627

1728
```php
1829
'Understand\UnderstandLaravel\UnderstandLaravelServiceProvider',
1930
```
2031

21-
3. Publish configuration file
32+
4. Publish configuration file
2233

2334
```
2435
php artisan config:publish understand/understand-laravel
2536
```
2637

27-
4. Set your input key in config file
38+
5. Set your input key in config file
2839

2940
```php
3041
'token' => 'my-input-token'
3142
```
3243

44+
6. Send your first event
45+
46+
```php
47+
// anywhere inside your Laravel app
48+
\Log::info('Understand.io test');
49+
```
50+
3351
### How to send events/logs
3452

3553
#### Laravel logs
3654
By default, Laravel automatically stores its logs in ```app/storage/logs```. By using this package, your logs can also be sent to your Understand.io channel. This includes error and exception logs, as well as any log events that you have defined (for example, ```Log::info('my custom log')```).
3755

56+
```php
57+
\Log::info('my message', ['my_custom_field' => 'my data']);
58+
```
59+
60+
[Laravel logging documentation](http://laravel.com/docs/errors#logging)
61+
62+
#### PHP/Laravel exceptions
63+
By default, All exceptions will be send to Understand.io service.
3864

3965
#### Eloquent model logs
4066
Eloquent model logs are generated whenever one of the `created`, `updated`, `deleted` or `restored` Eloquent events is fired. This allows you to automatically track all changes to your models and will contain a current model diff (`$model->getDirty()`), the type of event (created, updated, etc) and additonal meta data (user_id, session_id, etc). This means that all model events will be transformed into a log event which will be sent to Understand.io.
4167

4268
By default model logs are disabled. To enable model logs, you can set the config value to `true`:
4369

4470
```php
45-
'eloquent_logs' => true,
71+
'log_types' => [
72+
'eloquent_log' => [
73+
'enabled' => true,
4674
```
4775

4876
### Additional meta data (field providers)
@@ -53,7 +81,7 @@ You may wish to capture additional meta data with each event. For example, it ca
5381
* Specify additional field providers for each log
5482
* E.g. sha1 version session_id will be appended to each "Log::info('event')"
5583
*/
56-
'log_types' => [
84+
'log_types' => [
5785
'eloquent_log' => [
5886
'enabled' => false,
5987
'meta' => [
@@ -82,7 +110,7 @@ You may wish to capture additional meta data with each event. For example, it ca
82110
'env' => 'UnderstandFieldProvider::getEnvironment',
83111
'url' => 'UnderstandFieldProvider::getUrl',
84112
'method' => 'UnderstandFieldProvider::getRequestMethod',
85-
'client_id' => 'UnderstandFieldProvider::getClientIp',
113+
'client_ip' => 'UnderstandFieldProvider::getClientIp',
86114
'user_agent' => 'UnderstandFieldProvider::getClientUserAgent'
87115
]
88116
]
@@ -132,7 +160,7 @@ Lets assume that you have defined a custom field provider called `getCurrentTemp
132160
'laravel_log' => [
133161
'meta' => [
134162
...
135-
'UnderstandFieldProvider::getCurrentTemperature',
163+
'temperature' => 'UnderstandFieldProvider::getCurrentTemperature',
136164
...
137165
]
138166
],
@@ -149,7 +177,7 @@ This additional meta data will then be automatically appended to all of your Lar
149177
```
150178

151179

152-
### How to send data asynchnoously
180+
### How to send data asynchronously
153181
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 queue handler. To do this, change the config parameter `handler` to `queue` and Laravel queues will be automatically used. Bear in mind that by the default Laravel queue is `sync`, so you will still need to configure your queues properly using something like iron.io or Amazon SQS. See http://laravel.com/docs/queues for more information.
154182

155183
```php
@@ -208,7 +236,7 @@ return [
208236
'env' => 'UnderstandFieldProvider::getEnvironment',
209237
'url' => 'UnderstandFieldProvider::getUrl',
210238
'method' => 'UnderstandFieldProvider::getRequestMethod',
211-
'client_id' => 'UnderstandFieldProvider::getClientIp',
239+
'client_ip' => 'UnderstandFieldProvider::getClientIp',
212240
'user_agent' => 'UnderstandFieldProvider::getClientUserAgent'
213241
]
214242
]

src/config/config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
'env' => 'UnderstandFieldProvider::getEnvironment',
4848
'url' => 'UnderstandFieldProvider::getUrl',
4949
'method' => 'UnderstandFieldProvider::getRequestMethod',
50-
'client_id' => 'UnderstandFieldProvider::getClientIp',
50+
'client_ip' => 'UnderstandFieldProvider::getClientIp',
5151
'user_agent' => 'UnderstandFieldProvider::getClientUserAgent'
5252
]
5353
]
@@ -58,4 +58,4 @@
5858
*/
5959
'ssl_ca_bundle' => base_path('vendor/understand/understand-laravel/src/ca_bundle.crt')
6060

61-
];
61+
];

0 commit comments

Comments
 (0)