rootpd / nette-sentry
Nette Sentry logger library
Installs: 87 652
Dependents: 1
Suggesters: 0
Security: 0
Stars: 9
Watchers: 1
Forks: 9
Open Issues: 1
Requires
- php: ^8.1
- nette/di: ^3.0
- nette/http: ^3.0
- nette/security: ^3.0
- sentry/sentry: ^4.0
- tracy/tracy: ^2.4
Requires (Dev)
- ninjify/nunjuck: ^0.3
- squizlabs/php_codesniffer: ~3.5
README
Tracy logger extension capable of logging messages and errors to Sentry.
Note: If you have debug mode enabled in your application, logger will only send \Tracy\Debugger::log()
messages to sentry. Any exception ending with Tracy's blue screen is not going to be logged as you can see the exception details directly.
Installation
Install package via Composer:
composer require rootpd/nette-sentry
Configuration
Enable and configure the extension in Nette config file:
extensions: # ... sentry: Rootpd\NetteSentry\DI\SentryExtension sentry: dsn: https://123abc123abc123abc123abc123abc12@sentry.io/3 # required environment: production # optional, defaults to "local" user_fields: # optional, defaults to empty array; Nette's identity ID is being sent automatically - email session_sections: # optional, list of session sections to track - mySection priority_mapping: mypriority: warning
Priority-Severity mapping
Sometimes you might need to use custom priority when logging the error in Nette:
\Tracy\Debugger::log('foo', 'mypriority');
Sentry only allows strict set of severities. By default any message with unknown (non-standard) severity is not being logged.
You can map your custom priority to Sentry's severity in config by using priority_mapping
as shown in the example.
The allowed set of Sentry severities can be checked in Sentry's PHP repository.
Usage
Once enabled as extension, you can continue to throw exceptions without any change. To log message please use \Tracy\Debugger::log()
method.