Skip to content
CAI
Software that uses CAICheck a score

Seldaek/monolog

71.5

Strong · 13 November 2026

13.9k

lines of production code

PHP

primary language

7

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is Monolog, a PHP logging library that provides structured logging capabilities through a flexible handler, formatter, and processor architecture. It enables developers to capture, enrich, and serialize log records into various formats for diverse infrastructure targets, including cloud services, databases, and messaging platforms. The library supports modern PHP features and integrates with frameworks via attributes, while ensuring type safety and performance through strict typing and lazy evaluation mechanisms.

How it got here

2011 — Monolog 3.0 major release

11 changes.

This period marks the release of Monolog 3.0, a major overhaul requiring PHP 8.1+ and enforcing PSR-3 compliance through a new LogRecord object and Level enum. The architecture was refactored with modern handler hierarchies, new processors for context enrichment, and expanded formatter support for contemporary logging infrastructure. Comprehensive test coverage and strict static analysis were implemented to ensure stability across these breaking changes.

2012–2026 — Handler refactoring and PHP 8 attributes

9 changes.

This period focused on refactoring internal handler logic to improve type safety and maintainability, including the introduction of a dedicated UdpSocket class and the extraction of cURL retry mechanisms. It also introduced PHP 8 attributes for declarative configuration of processors and channels, alongside comprehensive test coverage updates for new and existing components like SlackRecord and MonologTestCase.

Features

New PHP attributes for configuring Monolog processors and channels

Added \AsMonologProcessor\ and \WithMonologChannel\ attributes to allow developers to declaratively configure logging processors and logger channels via PHP 8+ attribute syntax. \AsMonologProcessor\ supports targeting classes, methods, or parameters and allows specifying the channel, handler, method name, and priority for the processor. \WithMonologChannel\ targets classes or constructor/method parameters to indicate the expected logger channel. These attributes are metadata-only and require a third-party consumer (such as a framework bundle) to interpret and apply the configuration; they have no effect when used with the Monolog library alone.

src/Monolog/Attribute · high confidence

New UdpSocket class with configurable datagram length and Unix socket support

The SyslogUdp handler now uses a dedicated UdpSocket class that allows users to configure the maximum UDP datagram length to avoid packet fragmentation and loss, and supports sending logs via Unix sockets in addition to standard IPv4 UDP.

src/Monolog/Handler/SyslogUdp · high confidence

New and updated formatters for modern logging targets

The formatter component now includes dedicated formatters for ChromePHP, Elastica, Elasticsearch, Flowdock, Fluentd, GELF, Google Cloud Logging, HTML, Loggly, Logmatic, Logstash, and MongoDB, alongside updated versions of the Line, JSON, Normalizer, and Redacting formatters. These additions provide native support for serializing log records into formats required by modern infrastructure (such as Elasticsearch and GCP Logging) and tools (like ChromePHP and Fluentd), while the updated formatters introduce features like stack trace inclusion, sensitive data redaction, and improved normalization depth controls.

src/Monolog/Formatter · high confidence

New processors for context enrichment and lazy evaluation

This release adds several new processor classes to the src/Monolog/Processor directory to enrich log records with additional context. The new ClosureContextProcessor allows for lazy evaluation of context data by wrapping it in a closure, which is useful for reducing performance overhead in conditional logging scenarios. New GitProcessor and MercurialProcessor automatically inject repository branch and commit/revision information into log records. System-level context is now available via HostnameProcessor (injects hostname), LoadAverageProcessor (injects system load averages), and ProcessIdProcessor (injects the process ID). Memory monitoring is supported through MemoryProcessor (an abstract base class), MemoryUsageProcessor, and MemoryPeakUsageProcessor. Additionally, IntrospectionProcessor provides file, line, class, and function details from the call stack, while TagProcessor allows attaching custom tags to records. The UidProcessor has been updated to use random\_bytes for better uniqueness and includes a configurable length argument. The PsrLogMessageProcessor now supports removing used context fields after interpolation and handles UnitEnum values.

src/Monolog/Processor · high confidence

Behavioural changes

Activation strategies now use the new Level enum and LogRecord

The FingersCrossed handler's activation strategies (ChannelLevelActivationStrategy and ErrorLevelActivationStrategy) have been refactored to accept and compare against the new Level enum instead of raw integers or strings. This change ensures that level comparisons are type-safe and consistent with the rest of the library, as strategies now operate on LogRecord objects and Level instances, normalizing input via Logger::toMonologLevel.

src/Monolog/Handler/FingersCrossed · high confidence

Curl retry logic extracted to internal Util class

The retry mechanism for cURL requests has been moved into a new internal \Monolog\\Handler\\Curl\\Util\ class. This refactoring isolates the logic that handles transient errors (such as connection timeouts or DNS failures) by automatically retrying failed requests up to five times before throwing a \RuntimeException\. The class is marked as \@internal\ and \final\, meaning it is not part of the public API and may change without notice.

src/Monolog/Handler/Curl · high confidence

Handler architecture refactored for Monolog 2.0

The handler hierarchy has been restructured to support the new LogRecord object and modern PHP features. AbstractHandler now serves as the base class for level and bubbling logic, while AbstractProcessingHandler adds processor and formatter support. This change introduces a new handler structure that requires updating existing handler implementations to extend the new base classes.

src/Monolog/Handler · high confidence

Major architectural overhaul: new LogRecord model, Level enum, and ErrorHandler

Monolog has been refactored to use a new LogRecord class for log entries, replacing the previous array-based structure, and introduces a native Level enum to manage log levels (Debug through Emergency) with RFC 5424 support. The library now includes a dedicated ErrorHandler class to capture and log runtime errors, exceptions, and fatal errors, along with a SignalHandler for POSIX signal logging. Legacy classes like Log and Writer have been removed, and the Logger class now implements ResettableInterface to support resetting handlers and processors between requests or jobs.

src/Monolog · high confidence

Refactored Slack message formatting via new SlackRecord class

The logic for preparing Slack messages has been extracted into a dedicated \SlackRecord\ class, which now handles the construction of Slack attachments, color mapping, and context/extra data inclusion. This change introduces fluent setters for configuration, allows the channel to be optional (supporting webhooks), and ensures that context and extra variables are properly stringified even when nested more than one level deep. Users will see more consistent message formatting in Slack, with improved handling of special characters and attachment structures.

src/Monolog/Handler/Slack · high confidence

Repository initialization with PHP 8.1+ requirements and PSR-3 compliance

The repository has been initialized with a new structure and configuration, establishing Monolog 3.x as the current version. This release requires PHP 8.1 or higher and enforces PSR-3 compliance by converting log records from arrays to a \Monolog\\LogRecord\ object, replacing the previous \Logger::DEBUG\, \Logger::ERROR\, etc. constants with the \Monolog\\Level\ enum, and updating interfaces to accept \LogRecord\ instances. The project now includes a \.editorconfig\ for consistent coding standards, a \.php-cs-fixer.php\ configuration, and a \phpstan.neon.dist\ file with strict type checking (level 8). Documentation has been updated to reflect these changes, including an \UPGRADE.md\ guide for migrating from previous versions, and the \README.md\ has been refreshed to highlight the new requirements and supported frameworks.

(repo-wide) · high confidence

Test coverage

Added e2e test script for FrankenPhpHandler; Added test coverage for Monolog formatters; Added tests for Monolog PHP 8 attributes; Added unit tests for Monolog handler base classes and core handlers; Added unit tests for Monolog processor classes; Added unit tests for SlackRecord; Expanded test coverage for core Monolog components; New MonologTestCase helper class for testing log records; Update test bootstrap for strict types and PSR-4 autoloading.

Dependencies

Monolog 3.0 release with PHP 8.1+ and PSR-3 v3 support

This update introduces Monolog 3.0, which raises the minimum PHP version to 8.1 and updates the PSR-3 logger interface requirement to support versions 2.0 and 3.0. The package now provides psr/log-implementation version 3.0.0. Development dependencies have been updated to include PHPUnit 10/11, PHPStan 2, and various handler libraries like Elasticsearch 7/8, MongoDB 1.8/2.0, and Rollbar 4.0. The autoloading has been switched to PSR-4, and the branch alias is set to 3.x-dev for the main branch.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 72 → 71 (-0.2)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.

Lenses

  • Code Health 80 → 80 (-0.3)
  • Architecture 87 → 98 (+11.2)
  • Maturity 57 → 54 (-2.6)
  • Readiness 90 → 90 (-0.4)
  • Security 98 → 100 (+2.5)

Resolved (9)

  • Duplicate intent with confusing type signature. Both handlers target Elasticsearch/Elastica backends. The ElasticsearchHandler accepts Client|Client which is a redundant union type (likely a typo for Client|ElasticsearchClient or similar), while ElasticaHandler accepts Client (Elastica client). The naming convention Elastica vs Elasticsearch is inconsistent for what are effectively the same domain (search logging), and the type signature error in ElasticsearchHandler is a clear API defect.
  • Duplicated block (10 lines × 2) (src/Monolog/Handler/NewRelicHandler.php)
  • Duplicated block (10 lines × 5) (src/Monolog/Formatter/ChromePHPFormatter.php)
  • Duplicated block (16 lines × 2) (src/Monolog/Handler/InsightOpsHandler.php)
  • Duplicated block (6 lines × 2) (src/Monolog/Formatter/LineFormatter.php)
  • Off-boarding risk: anonymized user #1
  • Projects may be oversized for their cohesion
  • Rotate the exposed credentials — git history can't be un-committed
  • Secret: square-access-token (.github/workflows/continuous-integration.yml)

New (10)

  • Edited copies of one member (3 members, 11+ corresponding lines) (src/Monolog/Handler/FallbackGroupHandler.php)
  • Edited copies of one member (3 members, 9+ corresponding lines) (src/Monolog/Handler/FallbackGroupHandler.php)
  • Edited copy of a member (10 corresponding lines) (src/Monolog/Formatter/GelfMessageFormatter.php)
  • Edited copy of a member (11 corresponding lines) (src/Monolog/Handler/AbstractProcessingHandler.php)
  • Edited copy of a member (12 corresponding lines) (src/Monolog/Handler/RotatingFileHandler.php)
  • Edited copy of a member (14 corresponding lines) (src/Monolog/Handler/MailHandler.php)
  • Edited copy of a member (17 corresponding lines) (src/Monolog/Handler/SlackHandler.php)
  • Edited copy of a member (7 corresponding lines) (src/Monolog/Handler/FingersCrossedHandler.php)
  • Edited copy of a member (7 corresponding lines) (src/Monolog/Handler/FleepHookHandler.php)
  • Off-boarding risk: anonymized user #1

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

Seldaek/monolog was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 13 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 3bed304b1905fed5c30d172872f4d890cbb03c6a — the exact code this score is about.
  • Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.64+preprod-569132d3dfbe.