Skip to content
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

[RavenHandler] Add support for contexts #1214

Closed
wants to merge 2 commits into from

Conversation

rvalitov
Copy link
Contributor

@rvalitov rvalitov commented Nov 2, 2018

Originates from #1179, and problem discussion is available at Sentry.

Sentry provides contexts to add extra data to the log. But it's not supported in current release of RavenHandler. As a result, in Sentry we see empty info like this:

image

This PR fixes this, so that user can pass contexts field in the record, as a result we will see something like this:

image

Users can pass information to Sentry like this:

$logger = new Monolog\Logger('YOUR_LOG_NAME');
$client = new Raven_Client('YOUR_SECRET_KEY');
$stream = new RavenHandler($client);
$log->addNotice('Some information', [
    'contexts' => [
        'os' => [
            'name' => 'Windows',
            'version' => '10'
        ]
    ]
]);

It's also possible to pass the contexts using processors. Example:

$log->pushProcessor(function ($record) {
    $record['contexts'] = [
        'os' => [
            'name' => 'Windows',
            'version' => '10'
        ]
    ];
    return $record;
});

@mleczakm
Copy link

mleczakm commented Nov 2, 2018

Useful contribution (I could remove some part of my bundle ;) if it only were merged, thanks a lot) but - missing tests.

@rvalitov
Copy link
Contributor Author

rvalitov commented Nov 2, 2018

I'll try to add the tests later...

@Seldaek Seldaek closed this in 916b034 Nov 4, 2018
@Seldaek
Copy link
Owner

Seldaek commented Nov 4, 2018

I fixed this in a simpler way, that only allows contexts to be passed either in the context array or in the extra (which is where processors should put their data, not as a random key on the $record array).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants