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

Uploaded Python 3

File details

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

File metadata

  • Download URL: nulog-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 b67812f6c3c44b9d18bef2e7c1fb4ab2f72c4bc4a8a556ecc311e10582b78294
MD5 a823ae2d292003f84b8d06514d6e848c
BLAKE2b-256 bb8848f2e19c155951f14077ffc4465a34900c4b6fa9b5e6ab029feed4425953

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: nulog-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 29.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9a3418f278c854d231375f1eac708f22ddbefeda2f77dd62919ff46b1a48479e
MD5 1c1c3853bd8f9edc2930b8742e1633a1
BLAKE2b-256 8e4bd3354d934580bbdee676800018c26e05abf99a2e3ca7efd57dd20117c1d8

See more details on using hashes here.

Provenance

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