circuits-log
Safe HaskellNone
LanguageGHC2024

Circuit.Log

Description

Generic JSONL logs with YAML-frontmattered bodies.

Each line in the log is a JSON envelope { "id": N, "ts": "...", "from": "...", "to": [], "thread": ["...", ...], "body": "..." }. The body is expected to be a markdown string with optional YAML frontmatter.

from is the card basename; thread is the raw residual-of names the card depends on (backward edges, stamped verbatim — no id resolution). to is always empty: forward edges (feeds-into) are banned.

The reader tolerates the historical mixed schema: entries written before 19 Aug 2026 carry fromtothread; entries written between 19 Aug 2026 and the envelope restore carry only idtsbody. A missing fromthread defaults to ""[] on read.

Synopsis

Configuration

newtype LogConfig Source #

Configuration for a log file.

Constructors

LogConfig 

Fields

Instances

Instances details
Show LogConfig Source # 
Instance details

Defined in Circuit.Log

defaultLogConfig :: LogConfig Source #

Default log configuration.

Points at the coffee permanent archive. Override logPath for other logs.

Entries

data LogEntry Source #

One log entry.

Constructors

LogEntry 

Fields

Instances

Instances details
Show LogEntry Source # 
Instance details

Defined in Circuit.Log

readLog :: LogConfig -> IO [LogEntry] Source #

Read all entries from the log.

Fails on the first parse error. For fault-tolerant reading, use readLogEither.

readLogEither :: LogConfig -> IO [Either String LogEntry] Source #

Read all entries, preserving parse errors.

nextId :: [LogEntry] -> Int Source #

Next id for a log: one greater than the maximum existing id, or 1.

renderEntry :: LogEntry -> Text Source #

Render one entry as a single JSONL line.

appendEntry :: LogConfig -> Text -> [Text] -> Text -> IO () Source #

Append a new entry with the given from, thread, and body to the log.

formatUtc :: UTCTime -> Text Source #

Format a UTC time as YYYY-MM-DDTHH:MM:SSZ.