Skip to main content

cliffracer-logging

NATS log streaming, correlation-filtered sinks, structured logging setup and per-dispatch timing logs for cliffracer services.

Core uses loguru for its own log lines. This package is what configures logging: sinks, formats and files.

from cliffracer import CliffracerService, ServiceConfig, rpc
from cliffracer_logging import LoggingExtension

class Orders(CliffracerService):
    logging = LoggingExtension(to_nats=True)

    @rpc
    async def place(self, item: str) -> dict[str, str]:
        return {"ok": item}

LoggingExtension(to_nats=False, timing=True)

to_nats stream this service's logs to logs.<service>.<level>
timing log "<kind> <subject> <ms>ms" at DEBUG for every dispatch

health_details() reports {"to_nats": bool, "streaming": bool}. streaming is whether a sink is attached, so a service configured for NATS while its connection is down reports to_nats: true, streaming: false.

stop() removes the sink it added, using the handler id loguru returned when it was attached. A service that stops and starts again therefore has one sink.

What timing covers

timing measures whatever runs through the hook chain. Four kinds reach it today, and each appears as the first word of the log line: rpc, async_rpc, event and timer.

The container runs the chain for every dispatch, so new dispatch paths are timed automatically. This is verified by tests/unit/test_instrumentation_coverage.py.

Outbound calls are logged by core itself: call_rpc, call_async and broadcast_message each write their own line. connect and disconnect are visible through the container's NATS callbacks.

LoggingConfig.configure(service_name, ...)

Structured JSON or human-readable logging to console and rotating files. It is a @staticmethod, so call it on the class.

service_name is the first positional argument and is required. The level keyword is log_level, and it defaults to "INFO".

Correlation-filtered logging

setup_correlation_logging, get_correlation_logger and CorrelationLoggerMixin attach the current correlation id to every record.

Installed from PyPI, versioned in lockstep with cliffracer.

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

cliffracer_logging-1.0.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file cliffracer_logging-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cliffracer_logging-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cliffracer_logging-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fa2b6b7a9a86d5edb5aca5f8882f0b1a09900e32eb5bb55b30cac5a1e6a039d
MD5 d4f90baeefd0ad28846d47e121027a90
BLAKE2b-256 50d203167173793234d22586ff38728395bd3426cee42fd80938b21c3fae617d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 file

0.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page