-
Notifications
You must be signed in to change notification settings - Fork 8.2k
feat(logging): add logger module for backwards compatibility #9929
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
Conversation
- Introduced a new logger module to facilitate compatibility with lfx.logging. - The module re-exports `configure` and `logger` from `lfx.log`, ensuring seamless integration. - Updated unit tests to validate the new logger functionality and compatibility. This change enhances the logging capabilities and maintains backward compatibility with existing code.
WalkthroughAdds a new logging compatibility module that re-exports configure and logger from lfx.log.logger, and updates a unit test to import the re-exported logger while making minor whitespace adjustments. Changes
Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate 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 |
edwinjosechittilappilly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/backend/base/langflow/logging/logger.py (1)
1-3: Add a defensive import and a brief module docstring for clearer failure modes.If lfx isn’t present, raise a targeted ImportError; also document the shim.
Apply this diff:
-from lfx.log.logger import configure, logger - -__all__ = ["configure", "logger"] +"""Compatibility shim: re-exports `configure` and `logger` from `lfx.log.logger`.""" +try: + from lfx.log.logger import configure as configure, logger as logger +except ImportError as e: + raise ImportError( + "langflow.logging.logger requires the `lfx` package to be importable." + ) from e + +__all__ = ["configure", "logger"]
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/backend/base/langflow/logging/logger.py(1 hunks)src/backend/tests/unit/test_langflow_logging_compatibility.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
{src/backend/**/*.py,tests/**/*.py,Makefile}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code
Files:
src/backend/base/langflow/logging/logger.pysrc/backend/tests/unit/test_langflow_logging_compatibility.py
src/backend/tests/unit/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Files:
src/backend/tests/unit/test_langflow_logging_compatibility.py
src/backend/tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
src/backend/tests/**/*.py: Unit tests for backend code must be located in the 'src/backend/tests/' directory, with component tests organized by component subdirectory under 'src/backend/tests/unit/components/'.
Test files should use the same filename as the component under test, with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.
When writing component tests, inherit from the appropriate base class in 'src/backend/tests/base.py' (ComponentTestBase, ComponentTestBaseWithClient, or ComponentTestBaseWithoutClient) and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping'.
Each test in backend Python test files should have a clear docstring explaining its purpose, and complex setups or mocks should be well-commented.
Test both sync and async code paths in backend Python tests, using '@pytest.mark.asyncio' for async tests.
Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Validate input/output behavior and test component initialization and configuration in backend Python tests.
Use the 'no_blockbuster' pytest marker to skip the blockbuster plugin in tests when necessary.
Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.
Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.
Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.
Test Langflow's Messag...
Files:
src/backend/tests/unit/test_langflow_logging_compatibility.py
🧠 Learnings (2)
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test backward compatibility across Langflow versions in backend Python tests by mapping component files to supported versions using 'VersionComponentMapping'.
Applied to files:
src/backend/tests/unit/test_langflow_logging_compatibility.py
📚 Learning: 2025-08-07T20:23:23.569Z
Learnt from: edwinjosechittilappilly
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-08-07T20:23:23.569Z
Learning: Some Langflow starter project files and components still use `from loguru import logger` instead of the centralized structlog logger from `langflow.logging.logger`. These should be updated to ensure consistent structured logging across the entire codebase.
Applied to files:
src/backend/tests/unit/test_langflow_logging_compatibility.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: Ruff Style Check (3.13)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Lint Backend / Run Mypy (3.13)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Lint Backend / Run Mypy (3.12)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Test Starter Templates
- GitHub Check: Optimize new Python code in this PR
- GitHub Check: Run Ruff Check and Format
- GitHub Check: Update Starter Projects
- GitHub Check: Ruff Style Check (3.13)
🔇 Additional comments (2)
src/backend/base/langflow/logging/logger.py (1)
1-3: LGTM: minimal re-export meets the compat goal.Straightforward pass-through keeps API surface stable.
src/backend/tests/unit/test_langflow_logging_compatibility.py (1)
156-173: Avoid shadowinglogger; alias the second import.File: src/backend/tests/unit/test_langflow_logging_compatibility.py (lines 156–173)
Prevents accidental masking and clarifies intent.
Apply this diff to the embedded code string:
from langflow.logging import logger, configure -from langflow.logging.logger import logger +from langflow.logging.logger import logger as logger_via_moduleManual verification required: the ripgrep run returned no output — confirm no remaining direct
from loguru import loggerusages.
|
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (45.52%) is below the target coverage (55.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #9929 +/- ##
==========================================
- Coverage 23.25% 23.24% -0.01%
==========================================
Files 1090 1091 +1
Lines 39837 39839 +2
Branches 5530 5530
==========================================
- Hits 9264 9261 -3
- Misses 30402 30407 +5
Partials 171 171
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Hi how are you doing today |



configureandloggerfromlfx.log, ensuring seamless integration.This change enhances the logging capabilities and maintains backward compatibility with existing code.
Summary by CodeRabbit
No user-facing functionality changes; this release focuses on compatibility and test robustness.