WP Manifestindependent plugin directory
manifest / developer / wpdb-monolog

Bloom UX WPDB Monolog

Integrate monolog logging with $wpdb

★ 1stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/bloom-ux/wpdb-monolog/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

monolog with WordPress

Use monolog with WordPress and log errors to your database.

Installation

Install using composer: composer require bloom-ux/wpdb-monolog:dev-main.

It will install as a mu-plugin.

If you're using composer's autoloader, you're done.

Components

  • \bloom\WPDB_Monolog\WPDB_Handler → monolog handler that writes logs to your WordPress database.
  • \bloom\WPDB_Monolog\WP_CLI_Handler → monolog handler that writes logs to WordPress command line interface.
  • \bloom\WPDB_Monolog\WP_Processor → monolog processor that adds "extra" data to a monolog record.

Usage

Basic

There are some helper functions to ease the integration:

<?php
use function bloom\WPDB_Monolog\get_logger_for_channel;
use function bloom\WPDB_Monolog\set_channel_level;

$logger = get_logger_for_channel( 'MyCustomChannel' );
set_channel_level( $logger, 'production' === wp_get_environment_type() ? 400 : 100 );
$logger->info("Lorem ipsum dolor sit amet", array( 'foo' => 'bar' ) );

Custom

You can integrate the handler and/or processor as you see fit with your monolog integration.