PHPackages                             atk14/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. atk14/logger

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

atk14/logger
============

ATK14 Logger provides logging infrastructure for the ATK14 Framework

v0.3(3mo ago)01.7k2MITPHPPHP &gt;=5.6.0CI passing

Since Dec 1Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/atk14/Logger)[ Packagist](https://packagist.org/packages/atk14/logger)[ Docs](https://github.com/atk14/Logger)[ RSS](/packages/atk14-logger/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (8)Versions (5)Used By (2)

ATK14 Logger
============

[](#atk14-logger)

[![Tests](https://github.com/atk14/Logger/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/atk14/Logger/actions/workflows/tests.yml)

A lightweight logging library for PHP applications. Supports writing to files, stdout, and in-memory buffers, with configurable log levels and optional email notifications on errors.

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

[](#installation)

```
composer require atk14/logger
```

Basic usage
-----------

[](#basic-usage)

```
define("LOGGER_DEFAULT_LOG_FILE", "/path/to/app/log/app.log");

$logger = new Logger("import_articles");
$logger->start();

$logger->info("Starting import");
$logger->info("Total articles to import: " . count($articles));

// ...

$logger->warn("Article #42 is missing a thumbnail");
$logger->error("Database connection lost");

// Writes buffered messages to the log file and sends an email notification
// if a message at or above the notify_level was logged.
$logger->stop();
```

Output format:

```
2024-05-15 14:23:00 import_articles[12345]: START
2024-05-15 14:23:01 import_articles[12345]: Starting import
2024-05-15 14:23:01 import_articles[12345]: Total articles to import: 100
2024-05-15 14:23:02 import_articles[12345]: WARN: Article #42 is missing a thumbnail
2024-05-15 14:23:03 import_articles[12345]: ERROR: Database connection lost
2024-05-15 14:23:03 import_articles[12345]: STOP, running time: 0 min 3.00 sec

```

Log levels
----------

[](#log-levels)

MethodLevelInt`$logger->debug($msg)`debug-1`$logger->info($msg)`info0`$logger->warn($msg)`warn2`$logger->error($msg)`error4`$logger->security($msg)`security5For a custom level use `put_log()`:

```
$logger->put_log("Custom message", 3); // warn++
```

Output destinations
-------------------

[](#output-destinations)

By default, messages are written to a file. Multiple destinations can be combined:

```
// File only (default)
$logger = new Logger("my_app");

// Stdout only
$logger = new Logger("my_app", ["log_to_stdout" => true]);

// Both file and stdout
$logger = new Logger("my_app", ["log_to_file" => true, "log_to_stdout" => true]);

// In-memory buffer (accessible via $logger->buffer)
$logger = new Logger("my_app", ["log_to_buffer" => true]);
$logger->info("Hello");
$logger->flush();
echo $logger->buffer; // "2024-05-15 14:23:01 my_app[12345]: Hello\n"

// Also output to stdout when running in a terminal
$logger = new Logger("my_app", ["automatically_log_to_stdout_on_terminal" => true]);
```

Email notifications
-------------------

[](#email-notifications)

When `flush_all()` (or `stop()`) is called and at least one message at or above `notify_level` was logged, an email with the full log is sent.

```
define("LOGGER_DEFAULT_NOTIFY_EMAIL", "ops@example.com");

// Trigger email on warn (level 2) and above:
define("LOGGER_MIN_LEVEL_FOR_EMAIL_NOTIFICATION", 2);
```

Or configure per prefix (see [Prefix-based configuration](#prefix-based-configuration)).

Prefix-based configuration
--------------------------

[](#prefix-based-configuration)

Different scripts or tasks can be routed to separate log files with individual settings via the global `$LOGGER_CONFIGURATION` array. Wildcard patterns are supported.

```
$LOGGER_CONFIGURATION = [
    // Exact match
    "cache_remover" => [
        "log_file"    => "/var/log/app/cache_remover.log",
        "notify_email" => "ops@example.com",
        "notify_level" => "error",   // send email on error and above
        "no_log_level" => "debug",   // suppress debug messages from output
    ],

    // Wildcard: matches "import_articles", "import_data", etc.
    "import_*" => [
        "log_file"    => "/var/log/app/import.log",
        "notify_email" => "imports@example.com",
        "notify_level" => "warn",
    ],
];
```

More specific keys take precedence over wildcards.

Constructor options
-------------------

[](#constructor-options)

```
$logger = new Logger($prefix, $options);
```

OptionDefaultDescription`prefix``""`Application mark shown in every log line`default_log_file``LOGGER_DEFAULT_LOG_FILE`Path to the log file`log_to_file``true` (unless `log_to_stdout` is true)Write to log file`log_to_stdout``false`Write to stdout`log_to_buffer``false`Write to `$logger->buffer` (StringBuffer)`automatically_log_to_stdout_on_terminal``false`Also write to stdout when running in a terminal`disable_start_and_stop_marks``false`Suppress START/STOP lines`default_notify_email``LOGGER_DEFAULT_NOTIFY_EMAIL`Recipient for email notificationsConstants
---------

[](#constants)

ConstantDefaultDescription`LOGGER_DEFAULT_LOG_FILE``/tmp/logger.log`Default log file path`LOGGER_DEFAULT_NOTIFY_EMAIL``""`Default notification email (empty = disabled)`LOGGER_MIN_LEVEL_FOR_EMAIL_NOTIFICATION``99`Minimum level to trigger email (99 = disabled)`LOGGER_NO_LOG_LEVEL``-99`Messages at or below this level are suppressedLicense
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance81

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity51

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 ~1026 days

Total

4

Last Release

98d ago

PHP version history (2 changes)v0.1PHP &gt;=5.3.0

v0.2.1PHP &gt;=5.6.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/974278?v=4)[Jaromir Tomek](/maintainers/yarri)[@yarri](https://github.com/yarri)

---

Top Contributors

[![yarri](https://avatars.githubusercontent.com/u/974278?v=4)](https://github.com/yarri "yarri (52 commits)")

---

Tags

loggeratk14

### Embed Badge

![Health badge](/badges/atk14-logger/health.svg)

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

###  Alternatives

[analog/analog

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

3441.6M24](/packages/analog-analog)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2101.3M2](/packages/marvinlabs-laravel-discord-logger)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1871.6M3](/packages/justbetter-magento2-sentry)[inpsyde/wonolog

Monolog-based logging package for WordPress.

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

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

402.9M85](/packages/amphp-log)[apix/log

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

511.1M26](/packages/apix-log)

PHPackages © 2026

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