Skip to content

Setting Embedly logger to Rails.logger in Rails v4 seems to stop Rails logging from working #22

Open

Description

@floehopper

Adding the following in an initializer worked ok in Rails v3.2.13, but seemed to stop all logging output after upgrading to Rails v4.0.

Embedly.configure do |config|
  config.logger = Rails.logger
end

Activity

  1. romanbsd commented on Mar 13, 2014

    @romanbsd
    Contributor

    👍

    The problem is that Embedly changes the log_level of the provided logger. In fact, it shouldn't touch the externally provided logger, but only set the log level if the logger was created by embedly itself. The workaround for time being is the following monkey patch:

    class Embedly::Configuration
      def set_logger_level(true_or_false)
      end
    end
  2. dokipen commented on Mar 13, 2014

    @dokipen
    Contributor

    Thanks. Any chance I can get a pull request to fix this for real?

  3. romanbsd commented on Mar 13, 2014

    @romanbsd
    Contributor

    Frankly, I don't like the way it's currently designed. So I don't see a good way to fix it properly without breaking the current api. I would say that Embedly shouldn't do the log level setting at all. It should receive a Logger or instantiate one, expose the logger instance, and then the user can change the log level at will. For the most cases, I assume that the users are re-using some logger (probably Rails logger), so they would prefer to set the log level globally and that's it.

    And if you really want fine grain control over debugging things, then maybe it's better to have a debug method which would do something like:

    def debug(&blk)
      if debug?
        logger.info(&blk)
      end
    end
  4. dokipen commented on Mar 13, 2014

    @dokipen
    Contributor

    I think the only reason that setting the level is in there is for the CLI to support --verbose. Over time it somehow got lumped into "configuration". That should probably be moved to the CLI related code.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions