Skip to content

Commit 8d498f7

Browse files
author
root
committed
Initial commit, working logger for Sentry
0 parents  commit 8d498f7

File tree

6 files changed

+95
-0
lines changed

6 files changed

+95
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Magento 2.0 Sentry Logger
2+
3+
This extension will add the ability to log to [Sentry](https://github.com/getsentry/). Default for the minimal logging level is DEBUG, this is set in the extensions di.xml.
4+
5+
## Installation with composer
6+
* Include the repository: `composer require sebwite/magento2-sentry-logger`
7+
* Enable the extension: `php bin/magento --clear-static-content module:enable Sebwite_Sentry`
8+
* Upgrade db scheme: `php bin/magento setup:upgrade`
9+
* Clear cache
10+
11+
## Installation without composer
12+
* Download zip file of this extension
13+
* Place all the files of the extension in your Magento 2 installation in the folder `app/code/Sebwite/Sentry`
14+
* Enable the extension: `php bin/magento --clear-static-content module:enable Sebwite_Sentry`
15+
* Upgrade db scheme: `php bin/magento setup:upgrade`
16+
* Clear cache
17+
18+
## Configuration
19+
* Add the variable 'raven_dns' to your app/etc/env.php file. Example:
20+
21+
`
22+
'raven_dns' => 'https://****@sentry.domain.com/8',
23+
`
24+
25+
---
26+
[![Alt text](https://www.sebwite.nl/wp-content/themes/sebwite/assets/images/logo-sebwite.png "Sebwite.nl")](https://sebwite.nl)

Raven/Client.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php namespace Sebwite\Sentry\Raven;
2+
3+
use Raven_Client;
4+
5+
/**
6+
* Raven Client - Uses Raven DNS from env.php
7+
*
8+
* @package Sebwite\Sentry
9+
* @author Sebwite
10+
* @copyright Copyright (c) 2015, Sebwite. All rights reserved
11+
*/
12+
class Client extends Raven_Client
13+
{
14+
public function __construct()
15+
{
16+
$env = include $_SERVER['DOCUMENT_ROOT'] . '/../app/etc/env.php';
17+
18+
$options = [];
19+
$ravenDNS = array_key_exists('raven_dns', $env) ? $env['raven_dns'] : null;
20+
21+
parent::__construct($ravenDNS, $options);
22+
}
23+
}

composer.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "sebwite/magento2-sentry",
3+
"description": "Magento 2.0 Logger for Sentry",
4+
"type": "magento2-module",
5+
"version": "1.0.0",
6+
"license": [
7+
"OSL-3.0",
8+
"AFL-3.0"
9+
],
10+
"require": {
11+
"php": "~5.5.0|~5.6.0|~7.0",
12+
"magento/magento-composer-installer": "*",
13+
"raven/raven": "0.9.*"
14+
},
15+
"autoload": {
16+
"psr-4": { "Sebwite\\Sidebar\\": "" },
17+
"files": [ "registration.php" ]
18+
}
19+
}

etc/di.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
3+
<type name="\Monolog\Handler\RavenHandler">
4+
<arguments>
5+
<argument name="ravenClient" xsi:type="object">\Sebwite\Sentry\Raven\Client</argument>
6+
<argument name="level" xsi:type="object">300</argument>
7+
</arguments>
8+
</type>
9+
<type name="Magento\Framework\Logger\Monolog">
10+
<arguments>
11+
<argument name="handlers" xsi:type="array">
12+
<item name="system" xsi:type="object">\Monolog\Handler\RavenHandler</item>
13+
</argument>
14+
</arguments>
15+
</type>
16+
</config>

etc/module.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3+
<module name="Sebwite_Sentry" setup_version="2.0.0"/>
4+
</config>

registration.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
\Magento\Framework\Component\ComponentRegistrar::register(
4+
\Magento\Framework\Component\ComponentRegistrar::MODULE,
5+
'Sebwite_Sentry',
6+
__DIR__
7+
);

0 commit comments

Comments
 (0)