Skip to content

Add locale processor #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ Or, to configure the `UserDataProcessor` object:

See the `UserDataProcessor` source for full details.

##### `LocaleProcessor`

This processor attaches to the error report the current application locale as a tag.

```php
'processors' => [
Clowdy\Raven\Processors\LocaleProcessor::class,
],
```

## Credits

This package was inspired [rcrowe/Raven](https://github.com/rcrowe/Raven).
33 changes: 33 additions & 0 deletions src/Processors/LocaleProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Clowdy\Raven\Processors;

use Illuminate\Support\Facades\App;

/**
* This processor adds the current locale to an outgoing error report as a tag.
*/
class LocaleProcessor
{
/**
* Run the processor: attach locale tag to a Monolog record
*
* @param array $record Monolog record
* @return array $record
*/
public function __invoke(array $record)
{
$record['extra']['tags']['locale'] = $this->getLocale();
return $record;
}

/**
* Get the locale
*
* @return string
*/
public function getLocale()
{
return App::getLocale();
}
}