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

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

morningtrain/wp-logger
======================

Logger interface

v0.1.2(2y ago)0503MITPHP

Since May 3Pushed 2y ago3 watchersCompare

[ Source](https://github.com/Morning-Train/wp-logger)[ Packagist](https://packagist.org/packages/morningtrain/wp-logger)[ RSS](/packages/morningtrain-wp-logger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

WP Logger
=========

[](#wp-logger)

Make it easier to handle different levels of log.

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

[](#table-of-contents)

- [Introduction](#introduction)
- [Getting Started](#getting-started)
    - [Installation](#installation)
- [Dependencies](#dependencies)
- [Usage](#usage)
    - [Initializing package](#initializing-package)
    - [Use package](#use-package)
- [Contributing](#contributing)
- [Contributors](#contributors)
- [License](#license)

Introduction
------------

[](#introduction)

Make it easier to handle different levels of log.

Getting Started
---------------

[](#getting-started)

To get started install the package as described below in [Installation](#installation).

To use the tool have a look at [Usage](#usage)

### Installation

[](#installation)

Install with composer

```
composer require morningtrain/wp-logger
```

Dependencies
------------

[](#dependencies)

- [psr/log](https://packagist.org/packages/psr/log)

Usage
-----

[](#usage)

### Initializing package

[](#initializing-package)

First of all, to get `\Morningtrain\WP\Logger\Loggers\DatabaseLogger` to work, the migration needs to be run. This is done be running the following method:

```
\Morningtrain\WP\Logger\Logger::initializeMigration()
```

Initialize `\Morningtrain\WP\Logger\Logger` with a slug and an array of the loggers that needs to be registered.
For each logger, there is some levels, that can be registered for the specific logger.

```
\Morningtrain\WP\Logger\Logger::registerLoggers(
    'logger',
    [
        // Loggers
    ]
);
```

#### Loggers

[](#loggers)

Each logger has the following methods, to register what level(s) that is needed:

- `->registerLevel($level)`
- `->registerLevels([$level])`
- `->registerAllLevels()`

##### *Database Logger*

[](#database-logger)

Make it possible to save logs to the database.
Class: `\Morningtrain\WP\Logger\Loggers\DatabaseLogger`

```
\Morningtrain\WP\Logger\Logger::databaseLogger()
```

##### *File Logger*

[](#file-logger)

Make it possible to save logs to a file.
Class: `\Morningtrain\WP\Logger\Loggers\FileLogger`Parameters in callback:

- `string $filename`

```
\Morningtrain\WP\Logger\Logger::fileLogger($filename)
```

##### *Mail Logger*

[](#mail-logger)

Make it possible to send logs to multiple emails.
Class: `\Morningtrain\WP\Logger\Loggers\MailLogger`Parameters in callback:

- `array $emails`

```
\Morningtrain\WP\Logger\Logger::mailLogger($emails)
```

##### *Ray Logger*

[](#ray-logger)

Make it possible to send logs to a Ray client.
Class: `\Morningtrain\WP\Logger\Loggers\RayLogger`Parameters in callback:

- `bool $backtrace // Optional. If true, it will add backtrace`

```
\Morningtrain\WP\Logger\Logger::rayLogger()
```

#### Levels

[](#levels)

```
\Psr\Log\LogLevel::EMERGENCY
\Psr\Log\LogLevel::ALERT
\Psr\Log\LogLevel::CRITICAL
\Psr\Log\LogLevel::ERROR
\Psr\Log\LogLevel::WARNING
\Psr\Log\LogLevel::NOTICE
\Psr\Log\LogLevel::INFO
\Psr\Log\LogLevel::DEBUG
```

### Use package

[](#use-package)

To get the Logger, that has been registered, the method `\Morningtrain\WP\Logger\Logger::getLogger($slug)`, where the slug is needed.
When the logger is collected, there is a method, for each level, that can be call:

```
\Morningtrain\WP\Logger\Logger::getLogger('logger')
    ->emergency()
    ->alert()
    ->critical()
    ->error()
    ->warning()
    ->notice()
    ->info()
    ->debug()
```

Each of these methods that:

- `string $message`
- `array $context // Optional`

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

[](#contributing)

Thank you for your interest in contributing to the project.

### Bug Report

[](#bug-report)

If you found a bug, we encourage you to make a pull request.

To add a bug report, create a new issue. Please remember to add a telling title, detailed description and how to reproduce the problem.

### Support Questions

[](#support-questions)

We do not provide support for this package.

### Pull Requests

[](#pull-requests)

1. Fork the Project
2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
3. Commit your Changes (git commit -m 'Add some AmazingFeature')
4. Push to the Branch (git push origin feature/AmazingFeature)
5. Open a Pull Request

Contributors
------------

[](#contributors)

- [Martin Schadegg Brønniche](https://github.com/mschadegg)
- [Mathias Bærentsen](https://github.com/matbaek)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

---

Developed by

[![Morningtrain logo](https://camo.githubusercontent.com/e5c33559f0458f056816ab1a75dc9fe3bbd5a141e5d8630d85ec32fa45c01526/68747470733a2f2f6d6f726e696e67747261696e2e646b2f77702d636f6e74656e742f7468656d65732f6d74742d776f726470726573732d7468656d652f6173736574732f696d672f6c6f676f2d6f6e6c792d746578742e737667)](https://morningtrain.dk)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 78% 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 ~18 days

Total

3

Last Release

1076d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/278725?v=4)[morningtrain](/maintainers/morningtrain)[@morningtrain](https://github.com/morningtrain)

---

Top Contributors

[![matbaek](https://avatars.githubusercontent.com/u/2310644?v=4)](https://github.com/matbaek "matbaek (32 commits)")[![mschadegg](https://avatars.githubusercontent.com/u/11231039?v=4)](https://github.com/mschadegg "mschadegg (9 commits)")

### Embed Badge

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

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

###  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/api

API for OpenTelemetry PHP.

1933.0M214](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2322.9M248](/packages/open-telemetry-sdk)[pagemachine/typo3-formlog

Form log for TYPO3

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

PHPackages © 2026

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