Skip to content

[Bug] Wrong line number in workflow.logger #447

@ndtretyak

Description

@ndtretyak

Describe the bug

All the log records emitted by workflow.logger has the same file, path and lineno pointing to workflow.LoggingAdapter.log.

Minimal Reproduction

import logging
import sys

from temporalio import workflow


class Formatter(logging.Formatter):
    def format(self, record) -> str:
        return f"path: {record.pathname}"


formatter = Formatter()
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(formatter)
log = logging.getLogger("")
log.setLevel(logging.INFO)
log.addHandler(handler)


@workflow.defn
class Workflow:
    @workflow.run
    async def run(self) -> None:
        workflow.logger.info("message")

This prints <...>/temporalio/workflow.py instead of the file where workflow is defined.

Metadata

Metadata

Assignees

No one assigned

    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