PHPackages                             metarush/log-once - 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. metarush/log-once

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

metarush/log-once
=================

Log messages, usually error messages, only once and optionally get notified. No more flood of error logs with the same message.

v1.1.0(1mo ago)11441MITPHPPHP &gt;=7.4

Since Feb 13Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/metarush/log-once)[ Packagist](https://packagist.org/packages/metarush/log-once)[ RSS](/packages/metarush-log-once/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (14)Versions (7)Used By (1)

metarush/log-once
=================

[](#metarushlog-once)

Log messages, usually error messages, only once and optionally get notified. No more flood of error logs with the same message.

Install
-------

[](#install)

Install via composer as `metarush/log-once`

Sample usage
------------

[](#sample-usage)

```
use MetaRush\LogOnce\LogOnce;

$message = 'This is my log';

$hash = \crc32($message); // you can use any hash function of your choice e.g., \md5(), \sha1(), etc

(new LogOnce($adapter)) // see adapter examples below
    ->setTimeZone('UTC')
    ->setHash($hash)
    ->setLogMessage($message)
    ->setNotifiers($notifiers) // optional, see below
    ->log();
```

Log adapters
------------

[](#log-adapters)

### File system

[](#file-system)

```
use MetaRush\LogOnce\FileSystem\Adapter as FileSytemLogger;

$logDir = '/path/to/logs';

$adapter = new FileSytemLogger($logDir);
```

Note: To mark a log file as read, rename it with a `__ALREADYREAD` suffix e.g., `2021-01-01_00-00-00_+0000__12345__ALREADYREAD.log` or you can simply delete the file.

### PDO database (e.g., MySQL, PostgreSQL, SQLite)

[](#pdo-database-eg-mysql-postgresql-sqlite)

Create a table with ff. fields:

- `id` INTEGER PRIMARY KEY AUTOINCREMENT,
- `createdOn` DATETIME, // must use YYYY-MM-DD HH:MM:SS
- `hash` TEXT, // make length as long as your hash function's output e.g., if \\md5(), must be 32
- `message` TEXT, // make length as long your log messages
- `alreadyRead` INTEGER // will have 1 or 0 value, can be ENUM or UNSIGNED TINY INT if you want

```
use MetaRush\DataMapper\Builder as DataMapperBuilder;
use MetaRush\LogOnce\Pdo\Adapter as PdoLogger;

$dataMapper = (new DataMapperBuilder)
    ->setDsn('mysql:host=localhost;dbname=yourLogDb')
    ->setDbUser('user')
    ->setDbPass('pass');
    ->build();

$adapter = new PdoLogger($dataMapper, 'yourLogTable');
```

Note: To mark a log row as read, set the `alreadyRead` column to `1` or you can simply delete the row.

Notifiers
---------

[](#notifiers)

We use the package `metarush/notifier` as notifier

```
use MetaRush\Notifier\Pushover\Builder as PushoverNotifier;

// define a Pushover notifier

$pushoverNotifier = (new PushoverNotifier)
                        ->addAccount('pushover_app_key', 'pushover_user_key')
                        ->setSubject('test subject')
                        ->setBody('test body')
                        ->build();

// $emailNotifier = (new EmailNotifier)...; // optionally add other notifiers

$notifiers = [$pushoverNotifier, $emailNotifier];
```

Inject `$notifiers` in `->setNotifiers($notifiers)` to the sample usage above.

For more info on how to use other available notifiers such as email visit [metarush/notifier](https://github.com/metarush/notifier)

Viewing logs
------------

[](#viewing-logs)

A UI to view the logs is not included in this package. You can simply use whatever database admin tool you're using if you're using PDO logger, or manually view the file system, if you're using the File system logger.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance94

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

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

Every ~377 days

Recently: every ~471 days

Total

6

Last Release

32d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2efbbec5345d184bd2ffcb1c78f050fd7775cf1e52e64ab171e5673aaefc6daf?d=identicon)[zkwbbr](/maintainers/zkwbbr)

---

Top Contributors

[![zkwbbr](https://avatars.githubusercontent.com/u/45949485?v=4)](https://github.com/zkwbbr "zkwbbr (7 commits)")

---

Tags

logloggingloggererror-loggingerror\_logerror logger

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/metarush-log-once/health.svg)

```
[![Health](https://phpackages.com/badges/metarush-log-once/health.svg)](https://phpackages.com/packages/metarush-log-once)
```

###  Alternatives

[analog/analog

Fast, flexible, easy PSR-3-compatible PHP logging package with dozens of handlers.

3451.5M24](/packages/analog-analog)[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k7](/packages/inpsyde-wonolog)[amphp/log

Non-blocking logging for PHP based on Amp, Revolt, and Monolog.

402.6M70](/packages/amphp-log)[apix/log

Minimalist, thin and fast PSR-3 compliant (multi-bucket) logger.

511.0M18](/packages/apix-log)[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/packages/logtail-monolog-logtail)[dakatsuka/monolog-fluent-handler

Fluentd Handler for Monolog

12480.5k](/packages/dakatsuka-monolog-fluent-handler)

PHPackages © 2026

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