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.6.tar.gz (12.3 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.6-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: loguru_dagster-0.1.6.tar.gz
  • Upload date:
  • Size: 12.3 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.6.tar.gz
Algorithm Hash digest
SHA256 3ad3fb2a62f674869e48715d62fea80e2b0bf553cd8ecf38ba6d9cdf369a13ab
MD5 6b06ead609669eba2ead0623679e8530
BLAKE2b-256 6d1a439bf759728351025df7dd5bac33e478640a63f0c9b5cf82078b8d88f67e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loguru_dagster-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 13.8 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 47035530df69315db12f18b30f9eb291181d74888ef6c9512701f3a0ba5ee7df
MD5 560a2ecec70504e3036dbfb961849e5b
BLAKE2b-256 1b7be7f4d8aab4f08fabe9d1ac6e232ec02b9da8df2a6b38b9b1b1dbe398a864

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