Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log formats silently changed between versions #353

Closed
rhunter opened this issue Feb 27, 2013 · 3 comments
Closed

Log formats silently changed between versions #353

rhunter opened this issue Feb 27, 2013 · 3 comments

Comments

@rhunter
Copy link
Contributor

rhunter commented Feb 27, 2013

The default Logger format seems to have changed between Grape v0.2.6 and v0.3.1 -- such that our logs stopped recording timestamp and log level information.

I'm not sure if the older version had the "right" behaviour and it's now broken, or whether we relied on an inappropriate default and were just lucky.

$ git checkout v0.3.1
$ ruby -r bundler/setup -I lib -r grape -r grape/api -e "Logger.new(STDOUT).info 'hi'"
hi
$ git checkout v0.2.6
$ ruby -r bundler/setup -I lib -r grape -r grape/api -e "Logger.new(STDOUT).info 'hi'"
I, [2013-02-27T18:39:20.352350 #85986]  INFO -- : hi

Using the wonderful git bisect, I narrowed it down to commit 11576c8 -- XML support for entitiies -- but I can't figure out what the relevant change is.

ActiveSupport? i18n? Something else?

rhunter referenced this issue Feb 27, 2013
…rror instead of returning a string representation of a response. Failing formatters will get reported with a 500.
rhunter added a commit to rhunter/grape that referenced this issue Feb 28, 2013
Addresses issue ruby-grape#353 -- Log formats silently changed between versions

The default log format changes after `require 'active_support/core_ext/logger'`, and
of course `require active_support/all` brings in everything including loggers.

To change the format back to the default for a particular logger, you can
use `my_logger = Logger::Formatter.new`.
@rhunter
Copy link
Contributor Author

rhunter commented Feb 28, 2013

It turns out the ActiveSupport logger extensions (require 'active_support/core_ext/logger) change the default log format -- and after commit 11576c8, Grape required all of ActiveSupport including the logger extensions.

I see two solutions:

  • Grape goes back to using just the ActiveSupport parts it needs. I've sent a pull request with the necessary changes.
  • Grape 0.3+ decides to use all of ActiveSupport. Thus, any app that wants the standard Ruby log format must provide a logger that does so (my_logger.format = Logger::Format.new)

I guess it boils down to whether Grape "has an opinion" on logging.

What do you think?

@dblock
Copy link
Member

dblock commented Feb 28, 2013

If Grape doesn't need all of ActiveSupport, it shouldn't require it. I'll take your PR.

rhunter added a commit to rhunter/grape that referenced this issue Mar 1, 2013
Addresses issue ruby-grape#353 -- Log formats silently changed between versions

The default log format changes after `require 'active_support/core_ext/logger'`, and
of course `require active_support/all` brings in everything including loggers.

To change the format back to the default for a particular logger, you can
use `my_logger = Logger::Formatter.new`.
@dblock
Copy link
Member

dblock commented Mar 17, 2013

See #354, fixed.

@dblock dblock closed this as completed Mar 17, 2013
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

No branches or pull requests

2 participants