PHPackages                             nomad42/loggable - 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. nomad42/loggable

ActiveLibrary

nomad42/loggable
================

PSR-3 compatible log message interface

0.2.1(2y ago)04[2 PRs](https://github.com/NoMad42/Loggable/pulls)MITPHPPHP ^8.2

Since Jul 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/NoMad42/Loggable)[ Packagist](https://packagist.org/packages/nomad42/loggable)[ Docs](https://github.com/nomad42/loggable)[ GitHub Sponsors](https://github.com/NoMad42)[ RSS](/packages/nomad42-loggable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (7)Used By (0)

PSR-3 compatible log message interface
======================================

[](#psr-3-compatible-log-message-interface)

[![Latest Version on Packagist](https://camo.githubusercontent.com/20aec3ce60e88582c0fb9bf517c1074ede79d52e100b95034dcfddd112cd533b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f6d616434322f6c6f676761626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nomad42/loggable)[![Tests](https://camo.githubusercontent.com/a5e5d4f4ce52f2427b7ccd0691aa029a1d79b56881f1ebdb26c96c445513e562/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e6f6d616434322f6c6f676761626c652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/nomad42/loggable/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/b96432012d846fe1fc91f6a107e0a7d364b209c5d790ea7c0353e8542fd03290/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6f6d616434322f6c6f676761626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nomad42/loggable)

This package have [PSR-3](https://www.php-fig.org/psr/psr-3/) compatible log message interface. It can be useful for implementation messages that can be easily logged via `\Psr\Log\LoggerInterface::log` method.

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

[](#installation)

You can install the package via composer:

```
composer require nomad42/loggable
```

Usage
-----

[](#usage)

### Standardize the workflow with logging your exception.

[](#standardize-the-workflow-with-logging-your-exception)

Step 1.

Implement interface in your exception.

```
class MyAppException extends Exception implements Loggable
{
    public function getLevel(): string
    {
        return LogLevel::CRITICAL;
    }

    public function getContext(): array
    {
        return ['exception' => $this];
    }
}
```

Step 2.

At your error handler add one extra catch block.

```
$logger = new NullLogger();

try {
    throw new MyAppException('Oh no!');
} catch (Loggable $exception) { // log(
        $exception->getLevel(),
        $exception->getMessage(),
        $exception->getContext(),
    );
} catch (Exception $exception) {
    $logger->error('Oh no!', ['exception' => $exception]);
}
```

### Wrap existing exception and log it immediately

[](#wrap-existing-exception-and-log-it-immediately)

```
$exception = new \Exception('Oh no!');
$logger = new \Psr\Log\NullLogger();

LogMessage::makeFromException($exception)->logByLogger($logger);
```

### Log some data in easy way

[](#log-some-data-in-easy-way)

```
(new LogMessage(
    PsrLogLevel::INFO,
    'Cron task end successfully',
    ['metrics' => $metrics],
))->logByLogger($logger);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Arthur Makarov](https://github.com/NoMad42)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95% 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 ~3 days

Total

4

Last Release

1011d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/44b27bd38171657723173456565e87b597001d6628e736fb3fb4e12496a10f4b?d=identicon)[NoMad42](/maintainers/NoMad42)

---

Top Contributors

[![NoMad42](https://avatars.githubusercontent.com/u/19962558?v=4)](https://github.com/NoMad42 "NoMad42 (19 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

loggableNoMad42

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/nomad42-loggable/health.svg)

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

###  Alternatives

[gedmo/doctrine-extensions

Doctrine behavioral extensions

4.1k118.8M365](/packages/gedmo-doctrine-extensions)[stof/doctrine-extensions-bundle

Integration of the gedmo/doctrine-extensions with Symfony

1.9k85.3M381](/packages/stof-doctrine-extensions-bundle)[api-platform/metadata

API Resource-oriented metadata attributes and factories

223.5M96](/packages/api-platform-metadata)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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