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

Improvement to Langchain.logger #790

Open
3 of 4 tasks
andreibondarev opened this issue Sep 24, 2024 · 4 comments · Fixed by #804
Open
3 of 4 tasks

Improvement to Langchain.logger #790

andreibondarev opened this issue Sep 24, 2024 · 4 comments · Fixed by #804
Labels
enhancement New feature or request

Comments

@andreibondarev
Copy link
Collaborator

andreibondarev commented Sep 24, 2024

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

  • Instead of the method_missing approach, use the progname to set "[Langchain.rb]" in front of the logs.
  • 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.
  • Within the Langchain::Vectorsearch::* classes, make sure the different Net::HTTP, Faraday or client libraries are using the global Langchain.logger configuration.
@andreibondarev andreibondarev added the enhancement New feature or request label Sep 24, 2024
@dferrazm
Copy link
Contributor

dferrazm commented Sep 27, 2024

  • Instead of the method_missing approach, use the progname to set "[Langchain.rb]" in front of the logs.
  • 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.

@ajsharp
Copy link

ajsharp commented Nov 19, 2024

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

@andreibondarev
Copy link
Collaborator Author

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

@ajsharp
Copy link

ajsharp commented Nov 19, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants