Skip to content

Fix datetime_format to apply to custom formatters#155

Open
Rubyist007 wants to merge 1 commit into
ruby:masterfrom
Rubyist007:fix-datetime-format-with-custom-formatter
Open

Fix datetime_format to apply to custom formatters#155
Rubyist007 wants to merge 1 commit into
ruby:masterfrom
Rubyist007:fix-datetime-format-with-custom-formatter

Conversation

@Rubyist007

Copy link
Copy Markdown

Summary

  • Fix datetime_format= and datetime_format to delegate to the active
    formatter (@formatter or @default_formatter) instead of always using
    @default_formatter
  • Use respond_to? to gracefully handle formatters (e.g. Proc) that do not
    support datetime_format
  • Reorder initialize so datetime_format is set after the custom formatter
    is assigned

Fixes #154

Test plan

  • Added test_datetime_format_with_custom_formatter: verifies that
    datetime_format= applies to a custom formatter set after initialization
  • Added test_initialize_with_formatter_and_datetime_format: verifies that
    passing both formatter: and datetime_format: to Logger.new applies
    the format to the custom formatter
  • Existing test_datetime_format, test_initialize_with_formatter, and
    test_initialize_with_datetime_format continue to pass
datetime_format= and datetime_format always delegated to
@default_formatter, ignoring any custom formatter set via
Logger.new or formatter=. This also reorders initialize so
datetime_format is assigned after the custom formatter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant