Skip to main content

nulog

Logging + metrics as a Nu app. Append-only logs and kh57-backed metric series kept in nu.v, written and read in Nu. Every write is a Nu Command; every read is a Nu Query.

Usage

Everything happens inside a nulog.store(...) bracket. Writes are Nu Commands, reads are Nu Queries that yield list[dict] or dict[str, int].

import nu, nulog

tree = nu.With(nulog.store(),
    body=nu.v.Transaction(
        nulog.info("app", "server started", port=8080)
        >> nulog.warn("app", "cache miss", key="user:42")
        >> nulog.error("app", "request failed", path="/checkout", code=500)
        >> nulog.observe("cpu_load", 0.42)
    )
    >> nu.v.Snapshot(nu.print("tail:", nulog.tail("app", 3)))
    >> nu.v.Snapshot(nu.print("errors:", nulog.errors("app")))
    >> nu.v.Snapshot(nu.print("count:", nulog.count_by_level("app"))),
)

nu.run(tree)

Read atoms cover the search space:

  • Logs: tail(stream, n), head(stream, n), by_level(stream, level), errors(stream), since(stream, ts_us), between(stream, start_us, end_us), search(stream, text), count_by_level(stream).
  • Metrics: range_metric(name, begin, end), sample_metric(name, n, begin, end).

Rows come out as plain dicts. Log rows: {"key": int, "ts_us": int, "level": str, "msg": str, "fields": dict}. Metric rows: {"ts_us": int, "ts": float, "value": float}.

UI

The viewer is a bracket too: nulog.ui(streams, port=) boots a nudle server under nulog.store(...). Same shape as any Nu-nudle app.

import asyncio, nu, nulog

tree = nu.With(
    nulog.store("logs.db"),
    nulog.ui(["app", "scraper"], port=8080),
    body=nulog.info("app", "server started")
         >> nu.ForeverDo(
             nu.v.Transaction(nulog.info("app", "tick")) >> nu.Delay(1.5)
         ),
)

asyncio.run(nu.arun(tree))

Open http://127.0.0.1:8080: live newest-first entry table, stream switcher, level filter, message search, per-level count stats. The table + counts repaint every second off the same read atoms above.

Download files

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

Source Distribution

nulog-0.1.3.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

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

nulog-0.1.3-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file nulog-0.1.3.tar.gz.

File metadata

  • Download URL: nulog-0.1.3.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nulog-0.1.3.tar.gz
Algorithm Hash digest
SHA256 890ca953541c28d7b3212c9dc1c0517fb31fdee292ab61bf641b2ec4bbc4d02c
MD5 1ba5ef3d67013ab4d04d0d2be40961dc
BLAKE2b-256 88f840aec09328d7b305065b0066f59ffbaeb99403d0a7ec9b54d993d4937e03

See more details on using hashes here.

Provenance

The following attestation bundles were made for nulog-0.1.3.tar.gz:

Publisher: publish.yml on nustackdev/nulog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nulog-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: nulog-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nulog-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0d332011cc1215e7d7d6eae91dcfee1c6f303f4ef6a280ae5ec09b98f7253f63
MD5 d1b6eab2a8eac0757809d98b505437fc
BLAKE2b-256 e273bfc0f7c03098362b11bc5ff6eec1f6685b8e478dbe5a5e5627fd11c41be8

See more details on using hashes here.

Provenance

The following attestation bundles were made for nulog-0.1.3-py3-none-any.whl:

Publisher: publish.yml on nustackdev/nulog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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