Skip to content

Replace puts with injectable Logger instance#1

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/replace-puts-with-logger
Draft

Replace puts with injectable Logger instance#1
Copilot wants to merge 2 commits intomainfrom
copilot/replace-puts-with-logger

Conversation

Copy link

Copilot AI commented Mar 19, 2026

All puts calls used for error logging were replaced with a proper Logger instance that is configurable globally and injectable per-component, eliminating the need for allow_any_instance_of monkey-patches in tests.

Changes

  • Configuration — adds logger attr with default Logger.new($stdout), configurable via JSONRPC.configure
  • Middleware — accepts logger: option; defaults to config.logger; passes logger down to Validator
  • Validator — accepts logger: kwarg in constructor; defaults to config.logger for standalone use
  • middleware_spec — replaces allow_any_instance_of with a let(:app) that injects an instance_double(Logger) directly into the middleware; replaces output(...).to_stdout with have_received(:error)

Usage

# Default: Logger.new($stdout), no changes needed
JSONRPC.configure do
  self.logger = Logger.new($stderr, level: :warn)
end

# Or inject per-middleware instance
use JSONRPC::Middleware, path: '/rpc', logger: Rails.logger

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: wilsonsilva <645203+wilsonsilva@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace all instances of puts with Logger Replace puts with injectable Logger instance Mar 19, 2026
Copilot AI requested a review from wilsonsilva March 19, 2026 08:17
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.

2 participants