Skip to content

Commit c5ee8bb

Browse files
committed
Merge pull request #18 from tremby/locale-processor
Add locale processor
2 parents 08e5d5e + 20f58ae commit c5ee8bb

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ Or, to configure the `UserDataProcessor` object:
129129

130130
See the `UserDataProcessor` source for full details.
131131

132+
##### `LocaleProcessor`
133+
134+
This processor attaches to the error report the current application locale as a tag.
135+
136+
```php
137+
'processors' => [
138+
Clowdy\Raven\Processors\LocaleProcessor::class,
139+
],
140+
```
141+
132142
## Credits
133143

134144
This package was inspired [rcrowe/Raven](https://github.com/rcrowe/Raven).

src/Processors/LocaleProcessor.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Clowdy\Raven\Processors;
4+
5+
use Illuminate\Support\Facades\App;
6+
7+
/**
8+
* This processor adds the current locale to an outgoing error report as a tag.
9+
*/
10+
class LocaleProcessor
11+
{
12+
/**
13+
* Run the processor: attach locale tag to a Monolog record
14+
*
15+
* @param array $record Monolog record
16+
* @return array $record
17+
*/
18+
public function __invoke(array $record)
19+
{
20+
$record['extra']['tags']['locale'] = $this->getLocale();
21+
return $record;
22+
}
23+
24+
/**
25+
* Get the locale
26+
*
27+
* @return string
28+
*/
29+
public function getLocale()
30+
{
31+
return App::getLocale();
32+
}
33+
}

0 commit comments

Comments
 (0)