Download the PHP package baraja-core/tracy-sentry-bridge without Composer
On this page you can find all versions of the php package baraja-core/tracy-sentry-bridge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download baraja-core/tracy-sentry-bridge
More information about baraja-core/tracy-sentry-bridge
Files in baraja-core/tracy-sentry-bridge
Package tracy-sentry-bridge
Short Description The package provides an easy connection between Tracy and Sentry.
License
Homepage https://github.com/baraja-core/tracy-sentry-bridge
Informations about the package tracy-sentry-bridge
Tracy and Sentry Bridge
The package provides an easy connection between Tracy debugger and Sentry error tracking service. It allows you to automatically forward all Tracy log entries to Sentry while preserving the original Tracy logging functionality.
:bulb: Key Principles
- Seamless Integration: Works as a drop-in replacement for Tracy's default logger
- Dual Logging: All logs are sent to both the original Tracy logger and Sentry simultaneously
- No Data Loss: Original Tracy logs remain intact regardless of Sentry status
- Automatic Severity Mapping: Tracy log levels are automatically converted to appropriate Sentry severity levels
- Fault Tolerant: If Sentry logging fails, errors are captured by the fallback logger
- Zero Configuration: Simple one-line registration in your bootstrap
:building_construction: Architecture
The package implements Tracy's ILogger interface and uses the decorator pattern to wrap the original Tracy logger. This ensures that all existing logging functionality continues to work while adding Sentry integration on top.
:gear: Main Components
SentryLogger
The core class that implements Tracy's ILogger interface. It acts as a bridge between Tracy and Sentry.
Key Features:
| Feature | Description |
|---|---|
register() |
Static method to automatically register the logger with Tracy |
log() |
Main logging method that forwards to both Sentry and fallback logger |
| Severity Mapping | Automatic conversion of Tracy levels to Sentry severity |
| Exception Handling | Proper handling of both Throwable objects and string messages |
Severity Level Mapping
The package automatically maps Tracy log levels to Sentry severity:
| Tracy Level | Sentry Severity |
|---|---|
DEBUG |
debug |
INFO |
info |
WARNING |
warning |
ERROR |
error |
EXCEPTION |
error |
CRITICAL |
fatal |
Any unrecognized level defaults to fatal severity.
:package: Installation
It's best to use Composer for installation, and you can also find the package on Packagist and GitHub.
To install, simply use the command:
You can use the package manually by creating an instance of the internal classes, or register a DIC extension to link the services directly to the Nette Framework.
Requirements
- PHP 8.0 or higher
- Tracy ^2.8 or 3.0-dev
- Sentry SDK ^3.1
:rocket: Basic Usage
Quick Start with Nette Framework
In your project's Bootstrap.php file, initialize Sentry first and then register the bridge:
Standalone Usage
If you're not using Nette Framework, you can still use the package with standalone Tracy:
Manual Instantiation
For more control, you can manually create the logger instance:
:shield: Error Handling
The package is designed to be fault-tolerant:
-
Primary logging always works: The fallback (original Tracy) logger is called first, ensuring your local logs are always written.
-
Sentry failures are captured: If the Sentry logging fails for any reason, the exception is logged to the fallback logger with
CRITICALlevel. - Graceful degradation: If Sentry SDK is not properly loaded, the package will output a warning message but won't crash your application.
:zap: Advanced Configuration
Sentry Configuration Options
When initializing Sentry, you can customize various options:
Conditional Registration
You might want to only enable Sentry logging in production:
Logging Different Types
The bridge handles different value types appropriately:
:test_tube: Development & Testing
The package uses PHPStan for static analysis:
This runs PHPStan at level 8 with strict rules and Nette-specific extensions.
:busts_in_silhouette: Author
Jan Barasek - https://baraja.cz
:handshake: Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
:page_facing_up: License
baraja-core/tracy-sentry-bridge is licensed under the MIT license. See the LICENSE file for more details.