Skip to content

fix: change cost calculation logs from INFO to DEBUG level #12112

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

Conversation

colesmcintosh
Copy link
Collaborator

Title

fix: change cost calculation logs from INFO to DEBUG level

Relevant issues

Part 2/2 of fix for #9815

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

This PR changes cost calculation logs from INFO to DEBUG level to reduce log noise in production environments.

Problem

Cost calculation logs ("selected model name for cost calculation") were being emitted at INFO level, which is too verbose for production use. These logs should be debug-level information that's only shown when troubleshooting.

Solution

Changed verbose_logger.info() to verbose_logger.debug() for:

  1. Model selection logs in completion_cost() function
  2. Batch cost calculation logs in batch_cost_calculator() function

Testing

Added tests in test_cost_calculation_log_level.py that verify:

  • Cost calculation logs are emitted at DEBUG level
  • Batch cost calculation logs are emitted at DEBUG level

Test Output

tests/test_litellm/test_cost_calculation_log_level.py::test_batch_cost_calculation_uses_debug_level PASSED [ 50%]
tests/test_litellm/test_cost_calculation_log_level.py::test_cost_calculation_uses_debug_level PASSED [100%]
========================= 2 passed, 1 warning in 0.12s =========================

This is part 2 of a 2-part fix. The first PR (#12111) addresses the root cause by making loggers respect the LITELLM_LOG environment variable.

- Change verbose_logger.info() to verbose_logger.debug() for cost calculation messages
- Ensures cost calculation details are only shown when DEBUG logging is enabled
- Reduces log noise in production environments

Part 2/2 of fix for BerriAI#9815
Copy link

vercel bot commented Jun 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2025 5:44pm

@ishaan-jaff
Copy link
Contributor

cc @corbt

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@colesmcintosh colesmcintosh merged commit cce2656 into BerriAI:main Jun 27, 2025
6 checks passed
@corbt
Copy link

corbt commented Jun 28, 2025

Awesome, thanks!! Excited to see this in a release!

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.

3 participants