fix(logs): hide default service field in dev console
Fixes #13615.
Summary
- hide the default
service=langflowfield from human-oriented pretty console logs - keep service metadata in container/JSON logs for structured observability
- add regression coverage for
--devpretty console output
Tests
uv run pytest src/backend/tests/unit/test_logger.py -quv run ruff check src/lfx/src/lfx/log/logger.py src/backend/tests/unit/test_logger.pyuv run ruff format --check src/lfx/src/lfx/log/logger.py src/backend/tests/unit/test_logger.pygit 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.
[!IMPORTANT]
Review skipped
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.βοΈ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID:
11332a61-78e6-4091-9d2b-ef3d36514416You can disable this status message by setting the
reviews.review_statustofalsein 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.
Comment @coderabbitai help to get the list of available commands.
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.
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.