Skip to main content

Structlog processor to send logs to journald

Project description

structlog-journald

made-in-vietnam structlog-journald ReadTheDocs

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.2.0.tar.gz (107.2 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.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for structlog_journald-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cc8a10228df67159c9407419d58ab29fd11f52cf7b5e06793f270f2d04c13d5a
MD5 d624f54ed75675af3ab87cafa8eb30aa
BLAKE2b-256 daf2bcad7f30705c9564ed7d357caac2a8a1f5bd16dd32fdaf5d3e8f79a68b8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for structlog_journald-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9f69a698eb627a1fe69ca5d7b9f6d7e4c40324477263c9118b1ad8c5832ae49
MD5 c31665df52caaf08337adff36015b940
BLAKE2b-256 cb366e08888e153e2126baab9edc33b8132d5c35b96cedb4280f67e8f5607f5a

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