httplog不记录Rails 4应用程序发出的任何请求

时间:2017-04-23 20:58:13

标签: ruby-on-rails ruby net-http

我正在调试我的Rails应用程序,它会发出奇怪的请求(2而不是只有1个请求)。

我正在使用名为httplog的gem。我在Gemfile中添加了它,然后执行了bundle install

之后我在net / http gem之后需要httplog。

 require 'net/http'
 require 'json'  # => false
 require 'httplog' # require this *after* your HTTP gem of choice

然后我重新启动了我的应用并试图从我的应用程序发出请求。我的POST请求已执行但我没有看到httplog的任何内容。

我的日志:

Started GET "/users/auth/yandex/callback?state=b618f2a61ce3ce6b7a5xxxxxx2dd9755a3f9ec728b52ad959&code=32xxxx" for 212.3.194.120 at 2017-04-23 22:12:20 +0300
Processing by CallbacksController#yandex as HTML
  Parameters: {"state"=>"b618f2a61ce3ce6b7a5xxxxxx2dd9755a3f9ec728b52ad959", "code"=>"32xxxx"}
  [1m[35mUser Load (0.5ms)[0m  SELECT  `users`.* FROM `users`  WHERE `users`.`provider` = 'yandex' AND `users`.`uid` = '455934123'  ORDER BY `users`.`id` ASC LIMIT 1
  [1m[36m (0.2ms)[0m  [1mBEGIN[0m
  [1m[35mUser Exists (0.4ms)[0m  SELECT  1 AS one FROM `users`  WHERE `users`.`email` = BINARY 'xxxxx@yandex.ru' LIMIT 1
  [1m[36mSQL (0.3ms)[0m  [1mINSERT INTO `users` (`created_at`, `email`, `encrypted_password`, `provider`, `uid`, `updated_at`) VALUES ('2017-04-23 22:12:21', 'xxxx@yandex.ru', '$2a$10$.hZf/TKkqxxxxlNz6iuSMUiIdG1SAqg5KyXEaImAoHiNFNVJqS', 'yandex', '455934123', '2017-04-23 22:12:21')[0m
  [1m[35m (6.7ms)[0m  COMMIT
response   === {"error_description": "Code has expired", "error": "invalid_grant"} 2017-04-23 22:12:21 +0300
  [1m[36m (0.3ms)[0m  [1mBEGIN[0m
  [1m[35m (0.2ms)[0m  COMMIT
  [1m[36m (0.2ms)[0m  [1mBEGIN[0m
  [1m[35m (0.2ms)[0m  COMMIT
  [1m[36m (0.2ms)[0m  [1mBEGIN[0m
  [1m[35mSQL (0.7ms)[0m  UPDATE `users` SET `expires_in` = '2017-04-23 22:12:21', `updated_at` = '2017-04-23 22:12:21' WHERE `users`.`id` = 7
  [1m[36m (2.8ms)[0m  [1mCOMMIT[0m
  [1m[35m (0.2ms)[0m  BEGIN
  [1m[36mSQL (0.6ms)[0m  [1mUPDATE `users` SET `current_sign_in_at` = '2017-04-23 22:12:21', `current_sign_in_ip` = '212.3.194.120', `last_sign_in_at` = '2017-04-23 22:12:21', `last_sign_in_ip` = '212.3.194.120', `sign_in_count` = 1, `updated_at` = '2017-04-23 22:12:21' WHERE `users`.`id` = 7[0m
  [1m[35m (0.6ms)[0m  COMMIT
Redirected to http://xxxxx.ngrok.io/ru
Completed 302 Found in 424ms (ActiveRecord: 13.9ms)

注意:在上面的日志文件中,response === {"error_description": "Code has expired", "error": "invalid_grant"} 2017-04-23 22:12:21 +0300是对我的应用程序发出的POST请求的响应。

我认为HTTPLOG应该有一些类型吗?

我尝试了什么:

我在environments/development.rb

中添加了这一行
HttpLog.configure do |config|
 config.logger = Rails.logger
 config.color = {color: :black, background: :light_red}
end

然后重新启动服务器。但是在新服务器启动时我收到错误:

config/environments/development.rb:44:in `block in <top (required)>': undefined method `configure' for HttpLog:Module (NoMethodError)

我在这里做错了什么?

谢谢!

0 个答案:

没有答案