olog.cc

olog

The log is the state machine.

Ontology-organized logging for the AI era. Every log line is one typed state transition of one entity — so the log replays into a state machine, and the places where the code broke its own contract become the debugging output.

Read the skill The spec GitHub

Implementations: TypeScript · Go · Python · Rust · Java

Logging was built for eyes

Almost every logging system grew up around a human reading a terminal: printf templates, MDC, com.foo.Bar logger names, appenders and layouts, level enums, async queues, redaction layers, hundreds of lines of XML configuration.

An agent gets none of the value and all of the cost. It must parse a template to learn which argument landed where. It cannot tell what scope an MDC entry was in. It cannot tell whether the file on disk is XML or JSON. It gets a level — a human filter knob, not a fact about the system. It gets a stack trace: a blob of text no replay can reason about.

Meanwhile the thing a human actually does when debugging — folding the log back into state — has never been automatable, because the log threw the state away.

Keep the state

Say, on every line, which entity moved and from where to where. The ontology says what is legal.

{"seq":3,"ts":1764000000123,"run":"run-1",
 "type":"Request","id":"req-7","op":"running",
 "props":{"method":"GET","path":"/api/x"},
 "links":{"caused_by":["job-2"]}}
type	Request
enum	Request	state	queued,running,completed,failed
trans	Request	queued	running
trans	Request	running	completed
trans	Request	running	failed

One line of JSON, one event. One directive per line in the ontology. Nothing else to learn.

Replay is a fold

Fold the events in order and you get the state machine back. The fold can also fail loudly — and those failures are the answer.

AnomalyWhat it means
illegal_transitionThe code moved an entity somewhere the ontology forbids.
unknown_entityAn entity appeared without ever being created.
dangling_linkSomething referenced an entity that does not exist.
invalid_propAn event does not match the ontology's shape.

That anomaly list is the debugging output — not a stack trace to squint at, but a list of contract violations with the seq that caused each one.

Five actions

import { olog } from "olog";

const log = olog.open("./olog");

log.emit("Request", "req-7", "queued", { method: "GET", path: "/api/x" });
log.emit("Request", "req-7", "running");
log.emit("Request", "req-7", "completed", { code: 200 });

const { states, anomalies } = log.replay();

No logger object. No level. No formatter. No global state. Five actions: emit, link, replay, validate, open.

What was removed, and why

GoneBecause
levelA filter knob for human eyes. Severity belongs to a type — declare it as a property.
logger hierarchyA naming convention, not an ontology. The type is the grouping.
MDC / thread-local contextImplicit scope is unreadable. Put it in props or links.
printf templatesThe agent has to parse them. props is already structured.
appenders / layouts / encodersOne shape only: JSONL.
async queues / ring buffersWrite order stops matching event order, and replay becomes fiction.
redaction layerRedaction rewrites history; a replay of rewritten history is a lie. Redact before you emit.
samplingThe sampled-out stretch is a hole; replay reports phantom anomalies.

See it work

You declared that a request goes queued → running → completed. The code let req-8 skip running. The log says so, with the seq that did it.

$ npx olog replay ./olog

2 entities

  Request  req-7  completed
      code=200  method=GET  path=/api/x
  Request  req-8  completed
      code=500  method=POST  path=/api/y

1 anomaly

  seq   4  illegal_transition   Request req-8 cannot go from "queued" to "completed"

One command, and the CLI reads any olog log — whatever language wrote it. The format is the contract, not the implementation.

The one rule

A log line names a state, not a sentence. If you cannot say what state the entity moved to, you do not yet know what you are logging.

Read the skill The spec