Skip to content

Add support for logging to file via configuration #148

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

Merged
merged 2 commits into from
May 6, 2025

Conversation

rhys117
Copy link
Contributor

@rhys117 rhys117 commented May 3, 2025

Purpose

Introduces some basic configuration for the logging capabilities, allowing users to specify a custom log file and log level. This feature enhances debugging and monitoring capabilities by providing more control over where and how logs are recorded.

Implementation Details

  • Added log_file configuration option (default: STDOUT)
  • Added log_level configuration option (default: INFO, or DEBUG if RUBYLLM_DEBUG env var is set)
  • Updated logger initialisation to use the configured log file and level
  • Added documentation for logging configuration
  • Maintained backward compatibility with existing logging behaviour

Usage Example

# Global configuration
RubyLLM.configure do |config|
  config.log_file = '/logs/ruby_llm.log'  # Custom log file location
  config.log_level = :debug  # Set log level
end

Testing

Manual

  • Verified logger initialisation with custom log file
  • Confirmed log level changes based on configuration
  • Tested environment variable override for debug level
  • Validated default behaviour (STDOUT logging)

Documentation

Added a new section in configuration.md for logging settings

@crmne crmne merged commit 90cb088 into crmne:main May 6, 2025
5 checks passed
Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.65%. Comparing base (860dbfd) to head (bfc4f6a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #148   +/-   ##
=======================================
  Coverage   93.65%   93.65%           
=======================================
  Files          87       87           
  Lines        3199     3200    +1     
  Branches      422      422           
=======================================
+ Hits         2996     2997    +1     
  Misses        203      203           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

crmne added a commit that referenced this pull request May 6, 2025
## Purpose

Introduces some basic configuration for the logging capabilities,
allowing users to specify a custom log file and log level. This feature
enhances debugging and monitoring capabilities by providing more control
over where and how logs are recorded.

## Implementation Details

- Added log_file configuration option (default: STDOUT)
- Added log_level configuration option (default: INFO, or DEBUG if
RUBYLLM_DEBUG env var is set)
- Updated logger initialisation to use the configured log file and level
- Added documentation for logging configuration
- Maintained backward compatibility with existing logging behaviour

## Usage Example

```ruby
# Global configuration
RubyLLM.configure do |config|
  config.log_file = '/logs/ruby_llm.log'  # Custom log file location
  config.log_level = :debug  # Set log level
end
```

## Testing

Manual
- Verified logger initialisation with custom log file
- Confirmed log level changes based on configuration
- Tested environment variable override for debug level
- Validated default behaviour (STDOUT logging)

## Documentation

Added a new section in configuration.md for logging settings

Co-authored-by: Carmine Paolino <[email protected]>
sbounmy added a commit to sbounmy/ruby_llm that referenced this pull request May 12, 2025
…ith-image

* 'main' of github.com:crmne/ruby_llm: (24 commits)
  Enhance Rails guide with detailed persistence flow explanation and setup instructions
  Remove work-in-progress warning from models documentation generation
  Add validation considerations for Message model and update persistence flow documentation
  Add note about upcoming OpenAI headers support in v1.3.0
  Handle OpenAI organization and project IDs (crmne#162)
  Refactor acts_as_message and acts_as_tool_call methods to improve parameter handling and default values
  Remove reasoning section from available models documentation and rake task
  Remove debug logging for pricing in OpenRouter models
  Updated models page
  Fixed pricing parsing for OpenRouter
  Updated models
  Add warning about work in progress for Parsera integration in available models documentation
  Major refactoring of ModelInfo and Parsera API support for listing LLM capabilities and pricing.
  Fix inflector (crmne#159)
  Use foreign_key instead of to_s for acts_as methods (crmne#157)
  Fixes #embed fails when using default embedding model
  Add support for logging to file via configuration (crmne#148)
  Updated acts_as_* helpers to use canonical 'rails-style' foreign keys (crmne#151)
  refactor(media): streamline content formatting methods across providers
  Fixed Calling `chat.to_llm` keeps appending messages to the message array
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants