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.1.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.1-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nulog-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 34f3f3d5c3e18b68d95e193f69fdda4c3053ee21092227cb13c7ffda081ec2b4
MD5 c6d981f8131c4286e2c6cebae1e0f95f
BLAKE2b-256 8cba68729f481f43137ea06a257d675a0c41ded4e6ba302cecab430cb45b3941

See more details on using hashes here.

Provenance

The following attestation bundles were made for nulog-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: nulog-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eabe4c13629acc3060823a291da4ab6ab53ec3ec54f29eb71721012cc0bf6a98
MD5 a2373f6a910ab94adb5d18c07c0fa09e
BLAKE2b-256 cfd93e78cdd16e2bcf737d15b9a403c215e844941f04de1655f5653c97d3c910

See more details on using hashes here.

Provenance

The following attestation bundles were made for nulog-0.1.1-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