Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Varbase FAQs 9.2.1 Minor update available for module varbase_faqs (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module enhances Drupal's logging system by allowing you to add custom middleware. This middleware can modify or even discard log messages before they are processed. Functions as standard Drupal logging if no middleware is configured.

This module provides a customized LoggerChannel implementation with support for middleware. The logger channel and the logger channel factory extend the drupal core equivalents and just add support for middleware. Nothing else is altered in the logger channel implementation.

The module just provides support for middleware and does not provide middleware itself.

Without modules providing middleware the logger functions exactly the same as the drupal core one.

Adding Middleware

Each service tagged with log_middleware will automatically be attached to the logger channel and is applied before processing the log message.

A middleware can alter the log level, message and context. Additionally a middleware can discard a message entirely.

The service tag supports the following arguments:

  • priority: a numeric value indicating the order of which the middleware is run. The higher the number the earlier the middleware is applied. Negative values are allowed.
  • channels: an array with the logger channel names this middleware should be applied to. If empty, the middleware is applied to all channels.

All arguments are optional.

Example middleware implementations can be found in the ./tests/modules/log_test_middleware module.

Activity

Total releases
2
First release
Jan 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Release date
2.0.0 Stable Jan 20, 2025
2.x-dev Dev Jan 20, 2025