ruby-grape / ruby-grape/grape

Grape logger invalid

Open
#1,528 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs info
Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Description

in lib/grape/dsl/logger.rb, we can see:

module Grape
  module DSL
    module Logger
      include Grape::DSL::Settings

      attr_writer :logger

      # Set or retrive the configured logger. If none was configured, this
      # method will create a new one, logging to stdout.
      # @param logger [Object] the new logger to use
      def logger(logger = nil)
        if logger
          global_setting(:logger, logger)
        else
          global_setting(:logger) || global_setting(:logger, ::Logger.new($stdout))
        end
      end
    end
  end
end

Here is a problem, we can not set logger by Grape::API.logger = xxx, instead, we should call Grape::API.logger(xxx).

Seems something wrong with the attribute writter 'logger=' ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read lib/grape/dsl/logger.rb, starting with the logger method and the attr_writer :logger declaration, then check how Grape::API.logger= and Grape::API.logger(xxx) resolve. Confirm that assignment configures the logger as intended without breaking the existing method form.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.