Skip to content

Custom log info does not show in the log file #12805

@elcolie

Description

@elcolie

Bug Description

#5177 (comment)
I have followed the answer in order to see my custom log, but it does not show my log content.

Update 1st:
I drop all arguements in configure() then I can see my custom log message in the terminal.

Reproduction

.env

LANGFLOW_COMPONENTS_PATH=/home/sarit/codes/learn_langflow/
LANGFLOW_LOG_LEVEL=DEBUG
LANGFLOW_LOG_FILE=/home/sarit/codes/learn_langflow/logs/langflow.log
LANGFLOW_MAX_FILE_SIZE=4048
LANGFLOW_STORAGE_TYPE=local
LANGFLOW_ENABLE_LOG_RETRIEVAL=True

ocr_processor.py

from langflow.custom import Component
from langflow.io import MessageInput, Output
from langflow.schema.message import Message
from langflow.services.deps import get_storage_service, get_settings_service
import pytesseract
from PIL import Image
from pathlib import Path
from loguru import logger
from lfx.log.logger import configure


class OCRProcessor(Component):
    """Simple OCR processor class using Tesseract."""
    display_name: str = "OCR Processor"
    description: str = "Simple OCR processor using Tesseract."
    documentation: str = ""
    icon: str = "ScanText"
    name: str = "OCR Processor"

    inputs = [
        MessageInput(
            name="input_message",
            display_name="Input Message",
            info="Connect from Chat Input. User can attach an image file in the chat.",
        ),
    ]

    outputs = [
        Output(
            display_name="Extracted Text",
            name="extracted_text",
            method="process",
        ),
    ]


    def process(self) -> Message:
        #ipdb not work logger.info not work.
        # It is known issue. https://github.com/langflow-ai/langflow/discussions/3379
        message = self.input_message

        if not message.files:
            return Message(text="No image file attached. Please upload a JPEG or PNG image.")

        file_path = message.files[0]

        configure(log_level="info")
        logger.info("xxxxxxxxxxxxxxxxxxxxxxxxx")
        logger.info(f"Processing {file_path}")

        return Message(text="hi")

Expected behavior

I expect file_path in my log file.

Who can help?

No response

Operating System

24.05

Langflow Version

1.9

Python Version

3.11

Screenshot

No response

Flow File

Image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions