Skip to main content

nulog

Logging + metrics as a Nu app. Append-only logs and kh57-backed metric series kept in nu.kv, 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.kv.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.kv.Snapshot(nu.print("tail:", nulog.tail("app", 3)))
    >> nu.kv.Snapshot(nu.print("errors:", nulog.errors("app")))
    >> nu.kv.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.kv.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.4.tar.gz (32.6 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.4-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nulog-0.1.4.tar.gz
  • Upload date:
  • Size: 32.6 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.4.tar.gz
Algorithm Hash digest
SHA256 6d4e069e0da4c886342d0da6afe94c0e422c4f2b2d4ee946d6f1846f370dafec
MD5 61e8717ace26671cc56a0ed072b4e825
BLAKE2b-256 09b3c2a27864c418814033b669b6629d2d4d3a8278a4b918710ac30aa3a49c0b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: nulog-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 91eec957e15dc0eeec5fdd9c0f052ef389495bf22bf3645eaba66c13f98a770c
MD5 1390cc45d9ad79d6140e5cb94e622aaf
BLAKE2b-256 223b7365ca824344cd3bd146a0838f2a4df880018bee5bb3d52f57daf4219e65

See more details on using hashes here.

Provenance

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