Skip to content

fix: route custom Loguru logs through Langflow logger#12926

Open
erichare wants to merge 1 commit intorelease-1.10.0from
fix/custom-log-info
Open

fix: route custom Loguru logs through Langflow logger#12926
erichare wants to merge 1 commit intorelease-1.10.0from
fix/custom-log-info

Conversation

@erichare
Copy link
Copy Markdown
Collaborator

Summary

Fixes #12805.

Custom components that import logger directly from Loguru were bypassing Langflow's configured logging pipeline. As a result, messages such as logger.info(f"Processing {file_path}") could appear on stderr but not in the configured LANGFLOW_LOG_FILE, even when LANGFLOW_LOG_LEVEL=DEBUG and log retrieval/file logging were enabled.

This PR routes Loguru's default logger through Langflow's structlog configuration so those custom component messages reach the same sinks as the rest of Langflow logging. It also keeps repeated configure(...) calls from stacking duplicate rotating file handlers.

Root Cause

configure() configured Langflow's structlog logger and stdlib file handlers, but plain from loguru import logger usage kept Loguru's default sink. Custom component logs emitted through Loguru therefore skipped Langflow's configured file handler.

Changes

  • Add a small Loguru bridge that forwards Loguru records into the configured structlog pipeline.
  • Normalize invalid log levels before configuring Loguru, matching the existing structlog fallback behavior.
  • Track and replace Langflow's rotating file handler on reconfiguration to avoid duplicate file writes.
  • Add a regression test proving Loguru messages are written to the configured log file.

Validation

  • uv run ruff check src/lfx/src/lfx/log/logger.py src/backend/tests/unit/test_logger.py
  • uv run pytest src/backend/tests/unit/test_logger.py
  • Manual reproduction of the issue pattern confirmed loguru.logger.info("Processing /tmp/example.png") lands in LANGFLOW_LOG_FILE.

@erichare erichare linked an issue Apr 29, 2026 that may be closed by this pull request
@erichare erichare marked this pull request as ready for review April 29, 2026 14:29
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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: 7281f730-8707-482a-8aa1-f176d9c3aaf9

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/custom-log-info

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 and usage tips.

@github-actions github-actions Bot added the bug Something isn't working label Apr 29, 2026
Copy link
Copy Markdown
Member

@Cristhianzl Cristhianzl left a comment

Choose a reason for hiding this comment

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

lgtm

@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom log info does not show in the log file

2 participants