langchainrb
langchainrb copied to clipboard
Improvement to Langchain.logger
Is your feature request related to a problem? Please describe.
- [x] Instead of the method_missing approach, use the
prognameto 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.
- [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.
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
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
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!