Skip to main content

A bridge to integrate Loguru logging with Dagster context.log.

Project description

loguru-dagster

loguru-dagster is a lightweight utility package that bridges Loguru with Dagster.
It enables colorized, contextual logging inside Dagster pipelines with a single decorator.

🚀 Installation

pip install loguru-dagster

This will automatically install the required loguru and dagster dependencies.

📦 Import Path

from loguru_dagster import dagster_context_sink, with_loguru_logger

🧪 Usage Example

  1. Loguru Direct Logging You can use Loguru directly inside a Dagster asset:
import dagster as dg
from loguru import logger

@dg.asset
def test_loguru_html_log():
    """Verify that all levels appear correctly in Dagster UI"""
    logger.debug("==Debug== Loguru is working in Dagster!")
    logger.info("==Info== Loguru is working in Dagster!")
    logger.warning("==Warning== Loguru is working in Dagster!")
    logger.error("==!!Error!!== Loguru is working in Dagster!")
    return {"status": "done"}

defs = dg.Definitions(
    assets=[test_loguru_html_log]
)

Loguru Direct Logging

2.Bridge Loguru to context.log with Decorator To convert context.log calls into Loguru logs, use the decorator @with_loguru_logger from loguru_dagster:

import dagster as dg
from loguru_dagster import with_loguru_logger

@dg.asset
@with_loguru_logger
def my_contexlog_callig_loguru(context: dg.AssetExecutionContext) -> None:
    context.log.debug("This is a context.log.debug message from my_contexlog_callig_loguru")
    context.log.info("This is an context.log.info message from my_contexlog_callig_loguru")
    context.log.warning("This is a context.log.warning message from my_contexlog_callig_loguru")
    context.log.error("This is an context.log.error message from my_contexlog_callig_loguru")
    context.log.critical("This is a context.log.critical message from my_contexlog_callig_loguru")

defs = dg.Definitions(
    assets=[my_contexlog_callig_loguru]
)

Loguru Context Log Bridge

🔗 Repository

https://github.com/albertfast/loguru-dagster

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loguru_dagster-0.1.5.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loguru_dagster-0.1.5-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file loguru_dagster-0.1.5.tar.gz.

File metadata

  • Download URL: loguru_dagster-0.1.5.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for loguru_dagster-0.1.5.tar.gz
Algorithm Hash digest
SHA256 362adc49394b4d4489b6b5765b2a355ba917ea27042a7c764ce882b51d36d5b5
MD5 2b22c899fcb85df4d872ea9fe4cb882f
BLAKE2b-256 e555b5460fc326abf9ffaf00ee38e02f8687eab2f008980157c238313bd44085

See more details on using hashes here.

File details

Details for the file loguru_dagster-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: loguru_dagster-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for loguru_dagster-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 eac56f0584eaccc5bf3550a47c69d664d003d8561f6c23dea5ad810731053548
MD5 91fdd26801ba9dd4e7cacf559664b428
BLAKE2b-256 149e837351170d4166620234e746f6fb8a0f547fc9801bbddf6b13c2e9eae36c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page