-
Notifications
You must be signed in to change notification settings - Fork 8.2k
fix: expose logger functions at module level for backwards comp #10670
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
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughModule-level logger method aliases added to Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touchesImportant Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (5 passed)
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 |
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: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/backend/base/langflow/logging/logger.py(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: edwinjosechittilappilly
Repo: langflow-ai/langflow PR: 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.
Learnt from: edwinjosechittilappilly
Repo: langflow-ai/langflow PR: 0
File: :0-0
Timestamp: 2025-08-07T20:23:23.569Z
Learning: The Langflow codebase uses structlog for structured logging with a centralized configuration in `src/backend/base/langflow/logging/logger.py`. The configuration supports multiple output formats (JSON, CSV, console) based on environment settings and properly implements global log level filtering.
Learnt from: edwinjosechittilappilly
Repo: langflow-ai/langflow PR: 0
File: :0-0
Timestamp: 2025-08-07T20:23:23.569Z
Learning: The Langflow codebase has an excellent structlog implementation that follows best practices, with proper global configuration, environment-based output formatting, and widespread adoption across components. The main cleanup needed is updating starter project templates and documentation examples that still contain legacy `from loguru import logger` imports.
📚 Learning: 2025-08-07T20:23:23.569Z
Learnt from: edwinjosechittilappilly
Repo: langflow-ai/langflow PR: 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/base/langflow/logging/logger.py
🪛 GitHub Actions: Ruff Style Check
src/backend/base/langflow/logging/logger.py
[error] 19-19: Ruff: RUF022 'all' is not sorted.
🪛 GitHub Check: Ruff Style Check (3.13)
src/backend/base/langflow/logging/logger.py
[failure] 19-34: Ruff (RUF022)
src/backend/base/langflow/logging/logger.py:19:11: RUF022 __all__ is not sorted
⏰ 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). (13)
- GitHub Check: Validate PR
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- 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: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Run Backend Tests / LFX Tests - Python 3.10
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Test Starter Templates
- GitHub Check: Optimize new Python code in this PR
- GitHub Check: Update Starter Projects
- GitHub Check: Update Component Index
- GitHub Check: Run Ruff Check and Format
🔇 Additional comments (1)
src/backend/base/langflow/logging/logger.py (1)
11-17: The async logger methods are officially supported by structlog.structlog provides async variants (ainfo(), adebug(), aerror(), etc.) — added in v23.1.0 — which run the regular logging call asynchronously. The module-level aliases in lines 11-17 are valid and properly expose structlog's built-in async methods. The codebase already uses these methods successfully throughout (as seen in
src/lfx/src/lfx/utils/util.pyandsrc/lfx/src/lfx/components/olivya/olivya.py).Likely an incorrect or invalid review comment.
| # Expose logger methods at module level for backwards compatibility | ||
| info = logger.info | ||
| debug = logger.debug | ||
| warning = logger.warning | ||
| error = logger.error | ||
| critical = logger.critical | ||
| exception = logger.exception |
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.
🧩 Analysis chain
Verify that the logger object supports all aliased methods.
The module-level aliases for synchronous logging methods look correct. However, since logger is imported from the external lfx.log.logger module, ensure that it exposes all the standard logging methods being aliased here.
🏁 Script executed:
#!/bin/bash
# Description: Verify logger object has the expected methods by checking lfx library usage
# Search for usage of logger.info, logger.debug, etc. to confirm these methods exist
rg -n --type=py -C2 'logger\.(info|debug|warning|error|critical|exception)\(' | head -30Length of output: 2332
🏁 Script executed:
#!/bin/bash
# View the complete logging/logger.py file to see all aliases and __all__ list
cat src/backend/base/langflow/logging/logger.pyLength of output: 75
---
🏁 Script executed:
```shell
#!/bin/bash
# Search for logger.py files in the repository
fd -name "logger.py" -type f | head -20
Length of output: 230
---
🏁 Script executed:
```shell
#!/bin/bash
# Search for logger.py files
fd logger.py
Length of output: 145
---
🏁 Script executed:
```shell
#!/bin/bash
# View the target logger.py file
cat src/backend/base/langflow/logging/logger.py
Length of output: 680
---
🏁 Script executed:
```shell
#!/bin/bash
# View the lfx logger source to verify it has the async methods
cat src/lfx/src/lfx/log/logger.py
Length of output: 14237
---
🌐 Web query:
```web
structlog BoundLogger async methods support aerror ainfo
💡 Result:
Yes — structlog's BoundLogger provides async-prefixed methods (ainfo, aerror, adebug, awarning, alog, etc.). These were added in v23.1.0 (you can await log.ainfo(...)). The older AsyncBoundLogger wrapper exists but is deprecated in favor of the a-prefixed methods. [1][2]
Sources:
- structlog API docs (async variants added, usage example). [1]
- structlog.stdlib module docs (AsyncBoundLogger deprecation / details). [2]
Sort the __all__ list alphabetically to fix Ruff RUF022 violation.
The logger methods are correctly aliased—structlog's BoundLogger supports all requested sync methods (info, debug, warning, error, critical, exception) and async methods (ainfo, aerror, adebug, awarning, acritical, aexception) since v23.1.0. However, the __all__ list at lines 19-34 is not sorted alphabetically, causing the Ruff linter to fail. Reorder the list alphabetically: acritical, adebug, aerror, aexception, ainfo, awarning, configure, critical, debug, error, exception, info, logger, warning.
🤖 Prompt for AI Agents
In src/backend/base/langflow/logging/logger.py around lines 3-34, the __all__
export list is not alphabetized and triggers Ruff RUF022; reorder the entries in
the __all__ list to be alphabetically sorted as: acritical, adebug, aerror,
aexception, ainfo, awarning, configure, critical, debug, error, exception, info,
logger, warning so the linter passes.
| __all__ = [ | ||
| "configure", | ||
| "logger", | ||
| "info", | ||
| "debug", | ||
| "warning", | ||
| "error", | ||
| "critical", | ||
| "exception", | ||
| "aerror", | ||
| "ainfo", | ||
| "adebug", | ||
| "awarning", | ||
| "acritical", | ||
| "aexception", | ||
| ] |
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.
Fix the __all__ list sorting to resolve pipeline failure.
The __all__ list is not sorted alphabetically, causing the Ruff RUF022 check to fail. This is blocking the pipeline.
Apply this diff to sort the list:
__all__ = [
+ "acritical",
+ "adebug",
+ "aerror",
+ "aexception",
+ "ainfo",
+ "awarning",
"configure",
- "logger",
- "info",
+ "critical",
"debug",
- "warning",
"error",
- "critical",
+ "exception",
+ "info",
+ "logger",
- "exception",
- "aerror",
- "ainfo",
- "adebug",
- "awarning",
- "acritical",
- "aexception",
+ "warning",
]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| __all__ = [ | |
| "configure", | |
| "logger", | |
| "info", | |
| "debug", | |
| "warning", | |
| "error", | |
| "critical", | |
| "exception", | |
| "aerror", | |
| "ainfo", | |
| "adebug", | |
| "awarning", | |
| "acritical", | |
| "aexception", | |
| ] | |
| __all__ = [ | |
| "acritical", | |
| "adebug", | |
| "aerror", | |
| "aexception", | |
| "ainfo", | |
| "awarning", | |
| "configure", | |
| "critical", | |
| "debug", | |
| "error", | |
| "exception", | |
| "info", | |
| "logger", | |
| "warning", | |
| ] |
🧰 Tools
🪛 GitHub Actions: Ruff Style Check
[error] 19-19: Ruff: RUF022 'all' is not sorted.
🪛 GitHub Check: Ruff Style Check (3.13)
[failure] 19-34: Ruff (RUF022)
src/backend/base/langflow/logging/logger.py:19:11: RUF022 __all__ is not sorted
🤖 Prompt for AI Agents
In src/backend/base/langflow/logging/logger.py around lines 19 to 34, the
__all__ list is not alphabetically sorted which triggers Ruff RUF022; reorder
the entries in the __all__ list into strict alphabetical order (e.g., acritical,
adebug, aexception, ainfo, aerror, awarning, configure, critical, debug,
exception, error, info, logger, warning) preserving the same string names and
list formatting so the linter passes.
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (38.96%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #10670 +/- ##
==========================================
- Coverage 31.66% 31.65% -0.01%
==========================================
Files 1350 1350
Lines 61163 61175 +12
Branches 9142 9142
==========================================
- Hits 19368 19366 -2
- Misses 40879 40892 +13
- Partials 916 917 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Component Index merge conflict |
Exposes logger functions for backwards compat
Repro:
Upload to
main, try running. Get error:langflow.logging.logger has no attribute ainfo.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.