Skip to content

Load Logger when configuring custom logger delivery - #1671

Open
OskarEichler wants to merge 1 commit into
mikel:masterfrom
OskarEichler:codex/logger-mail
Open

OskarEichler wants to merge 1 commit into
mikel:masterfrom
OskarEichler:codex/logger-mail

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Require logger when the LoggerDelivery implementation loads, rather than only when constructing its default logger. A supplied logger currently bypasses that require and raises NameError while resolving the default or named severity in a fresh process.

Reproduction

Run in a fresh process against the gem:

require 'mail'
custom = Object.new
custom.define_singleton_method(:log) { |level, &block| [level, block.call] }
p Mail::LoggerDelivery.new(logger: custom).severity # => 1; previously NameError

Verification

  • Existing bundle exec rake spec: 1,837 examples, zero failures, four existing pending, both before and after this isolated patch, on Ruby 4.0.6 via rbenv.
  • External focused checks: 15 checks; 12 baseline failing expectations → zero.
  • Fresh process without a preloaded Logger; nil, symbol, string and integer severity; custom delivery receives the expected severity and encoded message. Existing logger specs preload logger and therefore miss the initial load-order failure. Existing Add Logger delivery method #856 introduction reviewed.
  • Targeted syntax and git diff --check pass. Supplementary Lint output retains the same 275 existing findings by file/cop/message.

Limitations and contribution policy

CONTRIBUTING.md and relevant existing specs were reviewed; a changelog entry is included. The requesting project's explicit no-new-tests policy prevents adding or modifying repository specs, so this PR supplies an inline reproduction and runs the existing suite plus external checks. This differs from upstream's request for a regression spec and may need maintainer follow-up. No claim of coverage completeness, other Ruby engines/versions, production throughput, or live delivery. Verification uses an external bundle with the consumer's patched network/mini_mime dependencies; benchmark is supplied externally for Ruby 4 (existing #1655/#1666), without changing the gem dependencies or CI.

Breaking changes

No intended breaking changes. Logger is already a runtime dependency and remains lazy with respect to require "mail"; it loads when LoggerDelivery is first used.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant