Skip to content

Add Monolog bridge for file-based job execution logging#199

Open
yann-eugone wants to merge 6 commits into1.xfrom
monolog-bridge
Open

Add Monolog bridge for file-based job execution logging#199
yann-eugone wants to merge 6 commits into1.xfrom
monolog-bridge

Conversation

@yann-eugone
Copy link
Copy Markdown
Contributor

Summary

  • Introduces the yokai/batch-monolog package — a new bridge that writes job execution logs to files using Monolog's StreamHandler, one file per job execution.
  • Adds optional subdirectory sharding (configurable depth and segment length) to avoid filesystem performance issues on large workloads.
  • Extends the Symfony bundle configuration with a new logging section supporting memory, null, stream (Monolog), and service logger types.
  • Documents the new concepts: the job execution logger abstraction, the Monolog bridge, and the Symfony Framework configuration.

New package: yokai/batch-monolog

The bridge exposes two classes:

  • StreamJobExecutionLoggerFactory — implements JobExecutionLoggerFactoryInterface. Creates one log file per job execution, named after the job execution id. Supports optional Monolog processors and a custom formatter. Files can optionally be spread across nested subdirectories (similar to how Git stores objects), to keep individual directories manageable at scale.
  • StreamJobExecutionLogger — implements JobExecutionLoggerInterface. Wraps a Monolog Logger with a StreamHandler. Reads logs back lazily via getLogs() or as a full string via getLogsContent(). The getReference() value stored with the JobExecution is the path relative to the configured directory, making it portable across environments.

Symfony bundle logging configuration

A new logging key is added to the bundle configuration tree:

yokai_batch:
  logging:
    type: stream          # memory | null | stream | service
    stream:
      directory: '%kernel.logs_dir%/batch'
      sub_directories: 2
      chars_per_directory: 2
      processors: []
      formatter: ~

When type: stream is selected, the bundle wires StreamJobExecutionLoggerFactory automatically.
When type: service, an arbitrary service id can be provided, allowing full customisation.

Documentation

New RST pages:

  • core-concepts/job-execution-logger.rst — explains what a job execution logger is, the factory lifecycle (create / restore), and lists all available implementations.
  • bridges/monolog.rst — usage examples for the three main scenarios: basic file logging, subdirectory sharding, and custom processors/formatter.

Updated pages:

  • bridges/symfony-framework.rst — documents the new logging bundle configuration.
  • core-concepts/job-execution.rst — links to the new logger page.
  • bridges.rst and index.rst — add the new Monolog bridge to the navigation tree.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.36%. Comparing base (9003a13) to head (954b707).
⚠️ Report is 3 commits behind head on 1.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                1.x     #199      +/-   ##
============================================
+ Coverage     99.32%   99.36%   +0.03%     
- Complexity      994     1054      +60     
============================================
  Files           172      175       +3     
  Lines          3114     3291     +177     
============================================
+ Hits           3093     3270     +177     
  Misses           21       21              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants