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

Uploaded Python 3

File details

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

File metadata

  • Download URL: nulog-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 1535de71355753d16d4dec4ff06071086b93d57d07dd2e140f1098fcec145dbc
MD5 6fce1b313714d05d3c2574a51069474a
BLAKE2b-256 69a296b0aaccceba8e205af5b00eacc857654aad91c17dc255567a7e3939c1f0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: nulog-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2935a08ae2fedd57d16a2a85339337fe4d0fa676f4111533186abf0f5dbaed5e
MD5 2ff66073d6ec44e2bdbb73beaf369fc0
BLAKE2b-256 3e64840fa24407c76daf401a69e5927fe27d04494da7700d388adff160306dce

See more details on using hashes here.

Provenance

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