Skip to content

Commit e51a2b1

Browse files
committed
doc: update usage example
1 parent 7701b85 commit e51a2b1

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# laravel-log-enhancement
22

33
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
4-
[![Travis](https://img.shields.io/travis/onramplab/laravel-log-enhancement.svg?style=flat-square)]()
4+
[![CircleCI](https://circleci.com/gh/OnrampLab/next-starter.svg?style=shield)]()
55
[![Total Downloads](https://img.shields.io/packagist/dt/onramplab/laravel-log-enhancement.svg?style=flat-square)](https://packagist.org/packages/onramplab/laravel-log-enhancement)
66

77

@@ -14,7 +14,40 @@ composer require onramplab/laravel-log-enhancement
1414

1515
## Usage
1616

17-
Write a few lines about the usage of this package.
17+
Use `LogWithClassPath` trait to let it automatically put class path into log context. You can refer to following code example.
18+
19+
```php
20+
namespace App;
21+
22+
use Onramplab\LaravelLogEnhancement\Concerns\LogWithClassPath;
23+
24+
class Fake {
25+
use LogWithClassPath;
26+
27+
public function run()
28+
{
29+
$this->info('Test');
30+
}
31+
}
32+
```
33+
34+
The log json will look like this:
35+
36+
```json
37+
{
38+
"message": "Test",
39+
"context": {
40+
"class_path": "App\\Fake"
41+
},
42+
"level": 200,
43+
"level_name": "INFO",
44+
"channel": "local",
45+
"extra": {},
46+
"timestamp": "2021-01-04T22:47:56.598608-0800"
47+
}
48+
```
49+
50+
1851

1952

2053
## Testing

0 commit comments

Comments
 (0)