PHPackages                             code-distortion/clarity-logger - 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. code-distortion/clarity-logger

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

code-distortion/clarity-logger
==============================

A Laravel package that generates useful logs

0.1.0(2y ago)07MITPHPPHP 8.0.\* | 8.1.\* | 8.2.\* | 8.3.\*CI failing

Since Dec 31Pushed 2y ago1 watchersCompare

[ Source](https://github.com/code-distortion/clarity-logger)[ Packagist](https://packagist.org/packages/code-distortion/clarity-logger)[ Docs](https://github.com/code-distortion/clarity-logger)[ RSS](/packages/code-distortion-clarity-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Clarity Logger - Useful Exception Logs
======================================

[](#clarity-logger---useful-exception-logs)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cd100727628330281b22363494f455950a26ec0fc8eb68f49b5e734e73b5bd34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64652d646973746f7274696f6e2f636c61726974792d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/code-distortion/clarity-logger)[![PHP Version](https://camo.githubusercontent.com/4359263e89771845b086ad2c059d7df9d332722f977037512184fa9dea74dfb2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e30253230746f253230382e332d626c75653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/4359263e89771845b086ad2c059d7df9d332722f977037512184fa9dea74dfb2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e30253230746f253230382e332d626c75653f7374796c653d666c61742d737175617265)[![Laravel](https://camo.githubusercontent.com/8ae51e76c8f9d6f0949d69e776278cce40f6dccdbb4ac57baae97b7beb4b12a1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d38253230746f25323031302d626c75653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/8ae51e76c8f9d6f0949d69e776278cce40f6dccdbb4ac57baae97b7beb4b12a1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d38253230746f25323031302d626c75653f7374796c653d666c61742d737175617265)[![GitHub Workflow Status](https://camo.githubusercontent.com/19bcfebb68103958053b3335e38027337032fef6387714b8135e8665e9000c1d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f64652d646973746f7274696f6e2f636c61726974792d6c6f676765722f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/code-distortion/clarity-logger/actions)[![Buy The World a Tree](https://camo.githubusercontent.com/dc3f77a9b22c3bc83c7b7d863bf138a7ca3418f1826b0b16d073d0aa87c16bc4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74726565776172652d2546302539462538432542332d6c69676874677265656e3f7374796c653d666c61742d737175617265)](https://plant.treeware.earth/code-distortion/clarity-logger)[![Contributor Covenant](https://camo.githubusercontent.com/902d296a65b2997bada7e7717fd929d9177f3bd95414cbb5ea2ed843c680f314/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e7472696275746f72253230636f76656e616e742d76322e3125323061646f707465642d6666363962342e7376673f7374796c653d666c61742d737175617265)](.github/CODE_OF_CONDUCT.md)

***code-distortion/clarity-logger*** is a Laravel package that generates useful exception logs.

```
EXCEPTION (CAUGHT):

exception     Illuminate\Http\Client\ConnectionException: "cURL error 6: Could not resolve host: api.example-gateway.com (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.example-gateway.com"
- location    app/Http/Controllers/CheckoutController.php on line 50 (method "submit")
- vendor      vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php on line 856 (closure)
request       POST https://my-website.com/checkout
- referrer    https://my-website.com/checkout
- route       cart.checkout
- middleware  web
- action      CheckoutController@submit
user          3342 - Bob - bob@example.com (123.123.123.123)
- agent       Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
date/time     Sunday 2nd April at 7:08pm (Australia/Sydney)  2023-04-02 19:08:23 AEST +10:00

```

Clarity Suite
-------------

[](#clarity-suite)

Clarity Logger is a part of the ***Clarity Suite***, designed to let you manage exceptions more easily:

- [Clarity Context](https://github.com/code-distortion/clarity-context) - Understand Your Exceptions
- **Clarity Logger** - Useful Exception Logs
- [Clarity Control](https://github.com/code-distortion/clarity-control) - Handle Your Exceptions

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
    - [Config File](#config-file)
- [Update Your Exception Handler](#update-your-exception-handler)
- [Manual Logging](#manual-logging)
- [Adding Some Context](#adding-some-context)

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

[](#installation)

Install the package via composer:

```
composer require code-distortion/clarity-logger
```

### Config File

[](#config-file)

Use the following command if you would like to publish the `config/code_distortion.clarity_logger.php` config file:

```
php artisan vendor:publish --provider="CodeDistortion\ClarityLogger\ServiceProvider" --tag="config"
```

Update Your Exception Handler
-----------------------------

[](#update-your-exception-handler)

Laravel projects use an [exception handler](https://laravel.com/docs/10.x/errors#the-exception-handler) class to log exceptions. You'll need to update this so Clarity Logger can log exceptions.

Add the following to the `register()` method of `app/Exceptions/Handler.php`.

If you use them, Laravel's own context details can be included by adding `$this->exceptionContext($e)`.

By default, Laravel adds the PHP's stacktrace to the log afterwards. You can turn this off if you like by adding `->stop()`.

```
// app/Exceptions/Handler.php

namespace App\Exceptions;

use CodeDistortion\ClarityLogger\Logger; // log($exception);
```

These methods can be chained:

```
Logger::channel('slack')->debug()->log($exception);
Logger::emergency()->channel('slack')->log('message');
```

Adding Some Context
-------------------

[](#adding-some-context)

If you add [Clarity Context](https://github.com/code-distortion/clarity-context) to your project (which lets you add context details to your code), Clarity Logger will include your context details automatically.

This can be a powerful tool when debugging exceptions. e.g.

```
EXCEPTION (UNCAUGHT):

exception     Illuminate\Http\Client\ConnectionException: "cURL error 6: Could not resolve host: api.example-gateway.com (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.example-gateway.com"
- location    app/Http/Controllers/CheckoutController.php on line 50 (method "submit")
- vendor      vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php on line 856 (closure)
request       POST https://my-website.com/checkout
- referrer    https://my-website.com/checkout
- route       cart.checkout
- middleware  web
- action      CheckoutController@submit
- trace-id    1234567890
user          3342 - Bob - bob@example.com (123.123.123.123)
- agent       Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
date/time     Sunday 2nd April at 7:08pm (Australia/Sydney)  2023-04-02 19:08:23 AEST +10:00

CONTEXT:

app/Domain/Checkout/PerformCheckoutAction.php on line 20 (method "handle")
- "Performing checkout"
- user-id = 5
- order-id = 123

app/Domain/Payments/MakePaymentAction.php on line 19 (method "handle") (last application frame)
- "Sending payment request to gateway"
- payment-gateway = 'examplexyz.com'
- card-id = 456
- amount = '10.99'

vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php on line 856 (closure)
- The exception was thrown

```

Testing This Package
--------------------

[](#testing-this-package)

- Clone this package: `git clone https://github.com/code-distortion/clarity-logger.git .`
- Run `composer install` to install dependencies
- Run the tests: `composer test`

Changelog
---------

[](#changelog)

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

### SemVer

[](#semver)

This library uses [SemVer 2.0.0](https://semver.org/) versioning. This means that changes to `X` indicate a breaking change: `0.0.X`, `0.X.y`, `X.y.z`. When this library changes to version 1.0.0, 2.0.0 and so forth, it doesn't indicate that it's necessarily a notable release, it simply indicates that the changes were breaking.

Treeware
--------

[](#treeware)

This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/code-distortion/clarity-logger) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

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

[](#contributing)

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

### Code of Conduct

[](#code-of-conduct)

Please see [CODE\_OF\_CONDUCT](.github/CODE_OF_CONDUCT.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Tim Chandler](https://github.com/code-distortion)

License
-------

[](#license)

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

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

868d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/56794290?v=4)[Tim](/maintainers/code-distortion)[@code-distortion](https://github.com/code-distortion)

---

Top Contributors

[![code-distortion](https://avatars.githubusercontent.com/u/56794290?v=4)](https://github.com/code-distortion "code-distortion (1 commits)")

---

Tags

loglaravelexceptionerrorContextreportcatch

### Embed Badge

![Health badge](/badges/code-distortion-clarity-logger/health.svg)

```
[![Health](https://phpackages.com/badges/code-distortion-clarity-logger/health.svg)](https://phpackages.com/packages/code-distortion-clarity-logger)
```

###  Alternatives

[guanguans/laravel-exception-notify

Monitor exception and report to the notification channels(Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

14642.7k1](/packages/guanguans-laravel-exception-notify)[yaro/log-envelope

Laravel 5 email on error

4147.0k](/packages/yaro-log-envelope)[rigor789/airbrake-laravel

Laravel package for the Airbrake API, which supports Errbit

1636.5k](/packages/rigor789-airbrake-laravel)

PHPackages © 2026

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