0

In the Gemfile, the gem is listed like this:

gem "faraday"

This leads to the installation of the current version 1.10.0.

Then, following this documentation, I create a custom logger, but I get an error:

NameError: uninitialized constant Faraday::Logging
Did you mean?  Logger

If open the Rails console and write the code Faraday::Logging::Formatter there, the error will be exactly the same.

Tell me, please, what is the matter and how to fix it?

UPD.

If I write this in the Rails console:

Faraday::Response::Logger::Formatter

Then I get this error:

NameError: uninitialized constant Faraday::Response::Logger::Formatter

Then I write this:

Faraday::Logging::Formatter

And there are no more errors. What is going on?

bundle exec rails c

Faraday::Logging::Formatter
=> NameError: uninitialized constant Faraday::Logging

Faraday::Logging::Formatter
=> NameError: uninitialized constant Faraday::Logging

Faraday::Response::Logger::Formatter
=> NameError: uninitialized constant Faraday::Response::Logger::Formatter

Faraday::Logging::Formatter
=> Faraday::Logging::Formatter
Colibri
  • 993
  • 11
  • 29
  • What `faraday` version are you using? – razvans Mar 15 '22 at 10:25
  • Faraday::Logging::Formatter was added from 1.x, most likely you are on 0.x – razvans Mar 15 '22 at 10:30
  • @razvans `This leads to the installation of the current version 1.10.0.` – Colibri Mar 15 '22 at 10:36
  • 2
    Oh, I missed it. Does `require 'faraday/logging/formatter'` in your console work? – razvans Mar 15 '22 at 10:41
  • @razvans This helped, thanks. Can I do something so that there is no double "require" and everything works through the console and as a normal running application? – Colibri Mar 15 '22 at 10:52
  • Pull the your custom formatter class in a file and `require 'faraday/logging/formatter'` at the top. Then call your formatter class where you need it. You don't have to require multiple times. – razvans Mar 15 '22 at 12:04

0 Answers0