langchainrb icon indicating copy to clipboard operation
langchainrb copied to clipboard

Improvement to Langchain.logger

Open andreibondarev opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe.

  • [x] Instead of the method_missing approach, use the progname to set "[Langchain.rb]" in front of the logs.
  • [x] Enable a way to output logs to a specified file path. (@dferrazm)
  • [ ] Within the Langchain::LLM::* classes, make sure the different Net::HTTP, Faraday or client libraries are using the global Langchain.logger configuration.
  • [x] Within the Langchain::Vectorsearch::* classes, make sure the different Net::HTTP, Faraday or client libraries are using the global Langchain.logger configuration.

andreibondarev avatar Sep 24 '24 17:09 andreibondarev

  • [X] Instead of the method_missing approach, use the progname to set "[Langchain.rb]" in front of the logs.
  • [X] Enable a way to output logs to a specified file path.

☝️ Fixed by #796


Within the Langchain::LLM::* classes, make sure the different Net::HTTP, Faraday or client libraries are using the global Langchain.logger configuration.

For that one ☝️ , I'll do in a different PR, since I still haven't gone through all the clients.

dferrazm avatar Sep 27 '24 18:09 dferrazm

Would also be great if langchain's logger was compatible with the rails logger. Currently trying to assign the rails logger to the langchain logger throws an error: NoMethodError: undefined method `debug?' for nil

ajsharp avatar Nov 19 '24 08:11 ajsharp

Would also be great if langchain's logger was compatible with the rails logger. Currently trying to assign the rails logger to the langchain logger throws an error: NoMethodError: undefined method `debug?' for nil

Hey @ajsharp, is this how you're assigning it?

[1] pry(main)> Langchain.logger = Rails.logger
=> #<ActiveSupport::Logger:0x0000000144e950f8
...
[2] pry(main)> Langchain.logger.debug?
=> true

andreibondarev avatar Nov 19 '24 13:11 andreibondarev

Sorry about this @andreibondarev -- this was an error on my part -- I was setting the logger in config/application.rb and I don't think the rails logger is initialized at that point. Setting it in an initializer fixes the issue. Sorry for the noise!

ajsharp avatar Nov 19 '24 16:11 ajsharp