PHPackages                             wpdesk/wp-logs - 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. wpdesk/wp-logs

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

wpdesk/wp-logs
==============

1.13.2(2y ago)057.2k5PHPPHP &gt;=7.4|^8CI failing

Since Oct 25Pushed 2mo agoCompare

[ Source](https://github.com/WP-Desk/wp-logs)[ Packagist](https://packagist.org/packages/wpdesk/wp-logs)[ RSS](/packages/wpdesk-wp-logs/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (7)Versions (38)Used By (5)

wp-logs — Logging Library for WordPress and WooCommerce
=======================================================

[](#wp-logs--logging-library-for-wordpress-and-woocommerce)

[![Latest Stable Version](https://camo.githubusercontent.com/b68bb6f5c34e2c0c54435803b176f515a19108ffe2f375522fe2991b19b08e96/68747470733a2f2f706f7365722e707567782e6f72672f77706465736b2f77702d6c6f67732f762f737461626c65)](https://packagist.org/packages/wpdesk/wp-logs)[![Total Downloads](https://camo.githubusercontent.com/382a3d6acd4d13c7865aa52d9a77aaf5a23db4b69ed54d51f96bb31ba7142ab1/68747470733a2f2f706f7365722e707567782e6f72672f77706465736b2f77702d6c6f67732f646f776e6c6f616473)](https://packagist.org/packages/wpdesk/wp-logs)[![License](https://camo.githubusercontent.com/5fbf2f6cf760976f80079dc9dad6f8fdc35fb4f12eb99efe8e564d03751fb172/68747470733a2f2f706f7365722e707567782e6f72672f77706465736b2f77702d6c6f67732f6c6963656e7365)](https://packagist.org/packages/wpdesk/wp-logs)

`wp-logs` is a modern, flexible logging library for WordPress and WooCommerce plugins. It is fully PSR-3 compliant and built on top of the Monolog 2 library.

The library helps plugin developers seamlessly route log messages to WooCommerce's log system (`WC_Logger`) or the standard WordPress debug log (`debug.log`).

---

Key Features
------------

[](#key-features)

- **PSR-3 Compliance:** Support for standard logging methods (`debug`, `info`, `warning`, `error`, etc.) and placeholder interpolation (e.g., `log('User {username} logged in', ['username' => 'john'])`).
- **Automatic WooCommerce Integration:** Logs automatically flow into WooCommerce's logger interface (found under WooCommerce -&gt; Status -&gt; Logs) via a dedicated handler.
- **Smart Fallback:** If WooCommerce is not active or initialized, the library falls back to the WordPress error log (`error_log`), provided the `WP_DEBUG_LOG` constant is enabled.
- **FingersCrossedHandler:** Optional log buffering that only writes messages if an error of a specific severity (e.g., `error`) occurs. This allows you to inspect full debug context for failing requests without cluttering the logs on success.
- **Sensitive Data Masking:** Includes a built-in processor to automatically mask sensitive information (such as passwords, API keys, or tokens) before writing logs.
- **Session Tracking:** Automatically attaches a unique session identifier (`uid`) to every log record in a request context, making log tracing straightforward in high-concurrency environments.

---

Requirements
------------

[](#requirements)

- **PHP:** `>= 7.4` or `^8.0`
- **WordPress:** `>= 5.0`
- **WooCommerce:** `>= 3.5.0` (for `WC_Logger` integration)
- **Monolog:** `^2.9.1`

---

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

[](#installation)

Install the package via [Composer](https://getcomposer.org/):

```
composer require wpdesk/wp-logs
```

### Inter-plugin Compatibility

[](#inter-plugin-compatibility)

In WordPress environments, multiple plugins may load the same library in different versions. To avoid version conflicts, we strongly recommend using a solution like [wpdesk/wp-autoloader](https://github.com/wpdesk/wp-autoloader) or a similar dependency isolation mechanism.

---

Usage
-----

[](#usage)

### 1. Basic Logging (SimpleLoggerFactory)

[](#1-basic-logging-simpleloggerfactory)

SimpleLoggerFactory is the recommended factory for creating logger instances.

```
use WPDesk\Logger\SimpleLoggerFactory;

// Initialize the factory with your plugin's channel name
$factory = new SimpleLoggerFactory('my-plugin-channel');

// Get the PSR-3 (Monolog) logger instance
$logger = $factory->getLogger();

// Log messages with different severity levels
$logger->debug('This is a diagnostic debug message');
$logger->info('User performed action {action}', ['action' => 'export']);
$logger->warning('Warning: Something went wrong, but we can recover.');
$logger->error('An error occurred while communicating with the API.');
```

### 2. Advanced Logging with FingersCrossedHandler

[](#2-advanced-logging-with-fingerscrossedhandler)

If you want to keep logs clean under normal circumstances but need full context when errors occur, use the `action_level` option:

```
use WPDesk\Logger\SimpleLoggerFactory;
use Psr\Log\LogLevel;

$options = [
    'level'        => LogLevel::DEBUG,  // Minimum log level for buffered records
    'action_level' => LogLevel::ERROR,  // Buffer will only flush to logs if a message of this level or higher is logged
];

$factory = new SimpleLoggerFactory('my-plugin-channel', $options);
$logger = $factory->getLogger();

// The following messages are kept in memory and won't write to disk yet...
$logger->debug('Started processing order...');
$logger->info('Fetched data from database.');

// ...until an error occurs.
// When an ERROR (or higher) is logged, the ENTIRE buffer (including debug & info) is flushed to the log file!
$logger->error('Failed to write order to the database!');
```

### 3. Masking Sensitive Data (SensitiveDataProcessor)

[](#3-masking-sensitive-data-sensitivedataprocessor)

Prevent credentials and API tokens from leaking into files using SensitiveDataProcessor:

```
use WPDesk\Logger\SimpleLoggerFactory;
use WPDesk\Logger\Processor\SensitiveDataProcessor;

$factory = new SimpleLoggerFactory('my-plugin-channel');
$logger = $factory->getLogger();

// Set up the processor with a mapping of search values to masked values
$sensitiveProcessor = new SensitiveDataProcessor([
    'super-secret-token' => '***MASKED_TOKEN***',
    'my_private_password' => '***MASKED_PASSWORD***'
]);

// Register the processor with Monolog
$logger->pushProcessor($sensitiveProcessor);

// Log message with sensitive information
$logger->info('Logging API key: super-secret-token');
// Output in log file: "Logging API key: ***MASKED_TOKEN***"
```

---

Legacy and Deprecated Methods (Backward Compatibility)
------------------------------------------------------

[](#legacy-and-deprecated-methods-backward-compatibility)

### WPDeskLoggerFactory and LoggerFacade

[](#wpdeskloggerfactory-and-loggerfacade)

The WPDeskLoggerFactory and LoggerFacade classes are deprecated since version 1.13.0. They write log entries to a shared file in `/wp-content/uploads/wpdesk-logs/wpdesk_debug.log`, which can lead to performance bottlenecks, write permission issues, and security vulnerabilities.

If your plugin still uses the legacy facades:

```
use WPDesk\Logger\LoggerFacade;

// Deprecated message logging
LoggerFacade::log_message('My debug message', [], 'source', \Psr\Log\LogLevel::DEBUG);

// Deprecated WP_Error / Exception logging
try {
    // some code...
} catch (\Exception $e) {
    LoggerFacade::log_exception($e);
}
```

**Recommendation:** Migrate your codebase to use the PSR-3 logger provided by SimpleLoggerFactory.

---

Running Tests
-------------

[](#running-tests)

The library contains unit and integration tests. PHPUnit is required to run the test suites.

To run the unit tests:

```
composer phpunit-unit
```

To run the fast unit tests (without code coverage):

```
composer phpunit-unit-fast
```

To run the integration tests:

```
composer phpunit-integration
```

---

License
-------

[](#license)

This project is licensed under the MIT License. See LICENSE.md for details.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance57

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 72.6% 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 ~62 days

Recently: every ~37 days

Total

35

Last Release

736d ago

Major Versions

0.1 → 1.02018-10-28

PHP version history (4 changes)0.1PHP &gt;=5.6

1.7.0PHP &gt;=7.0|^8

1.11.0-beta1PHP &gt;=7.2|^8

1.12.0PHP &gt;=7.4|^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/16497f8884c0767d3a114cc1cf8daaa639bac052178b03c59d59dfa95569d50b?d=identicon)[dyszczo](/maintainers/dyszczo)

![](https://www.gravatar.com/avatar/e6b9d73e70788735e2d8af0fba63affafdea243effde5eeae3e6fbb1e5d828e6?d=identicon)[grola](/maintainers/grola)

![](https://www.gravatar.com/avatar/97ac8b53a77161e994c106cc2136cf0601d404e5fd4a3295884d692c767636c7?d=identicon)[bjaskulski](/maintainers/bjaskulski)

![](https://www.gravatar.com/avatar/8e4b1bce6dad69911f85ab3abc19f8432db4a34a3b8a27043b90e82eab83e506?d=identicon)[eryk.mika](/maintainers/eryk.mika)

---

Top Contributors

[![dyszczo](https://avatars.githubusercontent.com/u/1263190?v=4)](https://github.com/dyszczo "dyszczo (85 commits)")[![bart-jaskulski](https://avatars.githubusercontent.com/u/56613051?v=4)](https://github.com/bart-jaskulski "bart-jaskulski (17 commits)")[![sebastianpisula](https://avatars.githubusercontent.com/u/15688144?v=4)](https://github.com/sebastianpisula "sebastianpisula (8 commits)")[![potreb](https://avatars.githubusercontent.com/u/2514438?v=4)](https://github.com/potreb "potreb (4 commits)")[![seostudio](https://avatars.githubusercontent.com/u/8124521?v=4)](https://github.com/seostudio "seostudio (3 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/wpdesk-wp-logs/health.svg)

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k39.6k](/packages/matomo-matomo)[laravel/framework

The Laravel Framework.

34.9k556.2M21.5k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k21](/packages/tempest-framework)[illuminate/log

The Illuminate Log package.

6225.7M692](/packages/illuminate-log)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

86337.5k](/packages/flow-php-flow)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)

PHPackages © 2026

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