langflow icon indicating copy to clipboard operation
langflow copied to clipboard

fix(logs): hide default service field in dev console

Open luochen211 opened this issue 5 months ago β€’ 3 comments

Fixes #13615.

Summary

  • hide the default service=langflow field from human-oriented pretty console logs
  • keep service metadata in container/JSON logs for structured observability
  • add regression coverage for --dev pretty console output

Tests

  • uv run pytest src/backend/tests/unit/test_logger.py -q
  • uv run ruff check src/lfx/src/lfx/log/logger.py src/backend/tests/unit/test_logger.py
  • uv run ruff format --check src/lfx/src/lfx/log/logger.py src/backend/tests/unit/test_logger.py
  • git diff --check

Summary by CodeRabbit

  • Tests

    • Added test case to verify that console logging output in development environment with pretty-print formatting correctly filters and hides the default service field identifier from logs.
  • Bug Fixes

    • Improved readability of console logs by implementing logic to strip default service metadata from all pretty-printed log output in development mode.

luochen211 avatar Jun 11 '26 09:06 luochen211

Review Change Stack

[!IMPORTANT]

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 11332a61-78e6-4091-9d2b-ef3d36514416

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • [ ] πŸ” Trigger review

Walkthrough

This PR introduces a structlog processor that removes the repetitive service=langflow field from human-oriented console logs. The processor is added to the pretty console renderer pipeline in development mode and is validated by a new unit test that confirms log messages appear without the default service metadata.

Changes

Service field filtering in pretty console logs

Layer / File(s) Summary
Service field filtering processor and validation
src/lfx/src/lfx/log/logger.py, src/backend/tests/unit/test_logger.py
A new structlog processor _hide_default_service_for_pretty_console removes the service field from log events when it equals the default value "langflow". The processor is wired into the pretty stdout rendering path in configure(). Test imports (importlib, re) and a new TestProductionObservability.test_dev_pretty_console_hides_default_service_field() method validate that log messages are rendered without the default service metadata in dev/pretty mode.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

πŸš₯ Pre-merge checks | βœ… 9
βœ… Passed checks (9 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title accurately describes the main change: hiding the default service field in dev console logs to reduce noise in pretty console output.
Linked Issues check βœ… Passed The code changes directly address issue #13615 by implementing a processor that removes the default service=langflow field from pretty console logs while preserving it in structured/JSON logs.
Out of Scope Changes check βœ… Passed All changes are directly related to fixing the repeating service field issue: a processor to hide the field in pretty console mode and a test to verify the behavior.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Test Coverage For New Implementations βœ… Passed PR includes a regression test test_dev_pretty_console_hides_default_service_field that properly validates the new _hide_default_service_for_pretty_console processor, verifying the fix for bug #...
Test Quality And Coverage βœ… Passed Test adequately covers main functionality: validates processor registration in pretty console mode and confirms default "langflow" service field is hidden via capsys output capture and ANSI strippi...
Test File Naming And Structure βœ… Passed Test file follows correct patterns: proper naming (test_*.py), logical pytest class organization, descriptive test names, comprehensive setup/teardown methods, proper fixture usage, edge cases, and...
Excessive Mock Usage Warning βœ… Passed Test uses appropriate fixtures (capsys, monkeypatch) for environment setup and output verification, not excessive mocks. Tests real logging system behavior with actual objects, following integratio...

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot] avatar Jun 11 '26 09:06 coderabbitai[bot]

Addressed the CodeRabbit nitpick: the pretty-console service-field test no longer implies DEV-specific behavior, and the unused DEV patch/import were removed. Re-verified with uv run pytest src/backend/tests/unit/test_logger.py -q, ruff check/format, and git diff --check.

luochen211 avatar Jun 11 '26 10:06 luochen211

CI looks blocked by runner/network setup rather than this PR change: both failed backend jobs stopped in astral-sh/setup-uv@v6 while resolving the latest uv release, ending with Github API request failed while getting latest release / Connect Timeout Error. A failed-job rerun should be enough, but I do not have repository admin permission to rerun the upstream workflow.

luochen211 avatar Jun 11 '26 23:06 luochen211