PHPackages                             itafroma/snaglogger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. itafroma/snaglogger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

itafroma/snaglogger
===================

A PSR-3 logger for Bugsnag

2.1.0(7y ago)130.1k3MITPHPPHP ~5.6 || ~7.0

Since Jan 3Pushed 4y ago1 watchersCompare

[ Source](https://github.com/itafroma/snaglogger)[ Packagist](https://packagist.org/packages/itafroma/snaglogger)[ Docs](https://marktrapp.com/projects/snaglogger)[ RSS](/packages/itafroma-snaglogger/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

Snaglogger
==========

[](#snaglogger)

Snaglogger is a PSR-3-compatible logger that sends log messages to [Bugsnag](https://bugsnag.com).

Installation
------------

[](#installation)

Snaglogger can be added to your project via [Composer](https://getcomposer.org):

```
{
    "require": {
        "itafroma/snaglogger": "^2.0"
    }
}
```

Snaglogger uses [semantic versioning](http://semver.org). In general, you can pin to `^[MAJOR].0` and be confident you will not receive breaking changes during updates.

Usage
-----

[](#usage)

### Quickstart

[](#quickstart)

Snaglogger comes with a factory that instantiates the logger with sensible defaults:

```
use Itafroma\Snaglogger\LoggerFactory;

$key    = 'YOUR BUGSNAG API KEY HERE';
$logger = LoggerFactory::create($key);
```

Once instantiated, the logger will work as any other PSR-3-compatiable logger:

```
$logger->info('This is an informational message.');
$logger->error('This is an error.');
```

### The PSR-3 context array

[](#the-psr-3-context-array)

Snaglogger will send the contents of the `$context` array to Bugsnag as [metadata](https://docs.bugsnag.com/platforms/php/other/#custom-diagnostics).

Additionally, Snaglogger treats two `$context` keys as special:

- If the `exception` key contains an instance of an exception, Snaglogger will record the log message as an exception instead of an error.
- If the `error-type` key is set, Snaglogger will use that as the error type. Otherwise, it will use the error severity.

Finally, Snaglogger will use the `$context` array for placeholder replacement within the log message:

```
$message = 'The {location} is on fire!';
$context = ['location' => 'roof'];

// Bugsnag will record the error message as "The roof is on fire!"
$logger->error($message, $context);
```

### Severity levels

[](#severity-levels)

Bugsnag only supports three severity levels: info, warning, and error. However, PSR-3 requires loggers to support eight: emergency, alert, critical, error, warning, notice, info, and debug. By default, Snaglogger maps these additional log levels to the closest Bugsnag severity level:

- emergency → error
- alert → error
- critical → error
- error → error
- warning → warning
- notice → info
- info → info
- debug → info

### Advanced usage

[](#advanced-usage)

Some functionality can be customized by implementing certain interfaces:

- Custom severity mapping: [`\Itafroma\Snaglogger\SeverityMapperInterface`](./src/SeverityMapperInterface.php)
- Custom message interpolation: [`\Itafroma\Snaglogger\MessageInterpolatorInterface`](./src/MessageInterpolatorInterface.php)

More information can be found in those interfaces' inline documentation.

You may also want to [customize the Bugsnag client](https://docs.bugsnag.com/platforms/php/other/configuration-options/).

To override Snaglogger's default functionality, you will need to:

1. Implement your own concrete class of [`\Itafroma\Snaglogger\LoggerFactoryInterface`](./src/LoggerFactoryInterface.php), and/or
2. Call the `Logger` constructor directly.

For example:

```
$client = Client::make('API KEY')->setReleaseStage('prod');
$interpolator = new CustomMessageInterpolator();
$mapper = new CustomSeverityMapper();

$logger = new Logger($client, $interpolator, $mapper);
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please see the separate [CONTRIBUTING](./CONTRIBUTING.md) file for more information.

Copyright and license
---------------------

[](#copyright-and-license)

This extension is copyright [Mark Trapp](https://marktrapp.com). All Rights Reserved. It is made available under the terms of the MIT license. A copy of the license can be found in the [LICENSE](./LICENSE) file.

Disclaimer
----------

[](#disclaimer)

This project has no affliation with Bugsnag in any way. Additional disclaimers can be found in the [LICENSE](./LICENSE) file.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 86.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~138 days

Total

5

Last Release

2860d ago

Major Versions

v1.0.1 → v2.0.02017-06-16

PHP version history (2 changes)v1.0.0PHP ~5.6.0 || ~7.0.0 || ~7.1.0

2.1.0PHP ~5.6 || ~7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/65391dc5aa04dbfa5e2abcb672705493d3f1f5c3e291d614c9ea77ff93519ff0?d=identicon)[itafroma](/maintainers/itafroma)

---

Top Contributors

[![itafroma](https://avatars.githubusercontent.com/u/277116?v=4)](https://github.com/itafroma "itafroma (13 commits)")[![ndelrossi](https://avatars.githubusercontent.com/u/6465291?v=4)](https://github.com/ndelrossi "ndelrossi (1 commits)")[![varvashenya](https://avatars.githubusercontent.com/u/4438707?v=4)](https://github.com/varvashenya "varvashenya (1 commits)")

---

Tags

bugsnagloggingpsr-3

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/itafroma-snaglogger/health.svg)

```
[![Health](https://phpackages.com/badges/itafroma-snaglogger/health.svg)](https://phpackages.com/packages/itafroma-snaglogger)
```

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[illuminate/log

The Illuminate Log package.

6224.3M518](/packages/illuminate-log)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2222.9M248](/packages/open-telemetry-sdk)[open-telemetry/api

API for OpenTelemetry PHP.

1833.0M214](/packages/open-telemetry-api)[pagemachine/typo3-formlog

Form log for TYPO3

23225.3k6](/packages/pagemachine-typo3-formlog)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
