Skip to main content

Structlog processor to send logs to journald

Project description

structlog-journald

made-in-vietnam structlog-journald ReadTheDocs Common Changelog

Structlog processor to send logs to journald.

Documentation: https://structlog-journald.readthedocs.io

Installation

To install structlog-journald, run:

pip install structlog-journald

You also need to install one of the journald binding implementations:

Usage

Add the structlog_journald.JournaldProcessor to your list of structlog processors.

To let the log has more useful information, you should also add these processors before JournaldProcessor:

  • CallsiteParameterAdder
  • format_exc_info

Example:

import logging

import structlog
from structlog_journald import JournaldProcessor


structlog.configure(
    processors=[
        structlog.contextvars.merge_contextvars,
        structlog.processors.add_log_level,
        structlog.processors.CallsiteParameterAdder(),
        structlog.processors.StackInfoRenderer(),
        structlog.processors.format_exc_info,
        structlog.dev.set_exc_info,
        structlog.processors.TimeStamper(fmt='%Y-%m-%d %H:%M:%S', utc=False),
        structlog.processors.EventRenamer('message'),
        JournaldProcessor(),
        structlog.dev.ConsoleRenderer(),
    ],
    wrapper_class=structlog.make_filtering_bound_logger(logging.NOTSET),
    context_class=dict,
    logger_factory=structlog.PrintLoggerFactory(),
    cache_logger_on_first_use=False,
)

log = structlog.stdlib.get_logger()

log.info('Hello, world!')

Journalctl

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

structlog_journald-0.3.0.tar.gz (87.7 kB view details)

Uploaded Source

Built Distribution

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

structlog_journald-0.3.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file structlog_journald-0.3.0.tar.gz.

File metadata

  • Download URL: structlog_journald-0.3.0.tar.gz
  • Upload date:
  • Size: 87.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.11

File hashes

Hashes for structlog_journald-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cedd51a2abd0b2a3de2831fb0aabd160bdf123868d10deed2bc93e604c6a6618
MD5 3546fbf0a6afd5fafe819f142266d34d
BLAKE2b-256 2bbfd33c7cba0ea5476044e9c69bce09cf1b9bd472368d5bec31b33478abdfdb

See more details on using hashes here.

File details

Details for the file structlog_journald-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for structlog_journald-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7748b883b7251e92490e2e9bc74863687160930a7b5e8d7678aad1975f9e38ef
MD5 89b949153dee03a3c47f292548926457
BLAKE2b-256 4f05ebb399c084d42b5c16037bb75bcbebb8d1cd45b42e31559206698537ebfa

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