Overview
Scriptorium.Parchment is the structured logging layer for the Scriptorium family. It exposes severity-based logging methods, a composable sink system, and child loggers with automatic prefixes.
Installation
Section titled “Installation”dotnet add package Scriptorium.ParchmentCreate a logger with one or more sinks, then call the severity method you need:
open Scriptorium.Parchmentopen Scriptorium.Parchment.Sinks
let logger = Parchment.Create(Universal.console ())
logger.info "Server started on port 3000"logger.warning "Deprecated API called"logger.error "Connection failed"logger.infof "Processing %d items" itemCount
// Child loggers prefix every message automaticallylet db = logger.Child("db")db.info "connected" // → [db] connecteddb.error "query failed" // → [db] query failedSix severity levels are available, from highest to lowest priority:
error > warning > info > verbose > debug > sillyEach has a plain and a formatted (f-suffixed) variant.
Filtering
Section titled “Filtering”Set logger.Level to suppress messages below a given severity. The default is Info.
logger.Level <- Severity.Warning
logger.error "logged" // ✓ Error ≤ Warninglogger.warning "logged" // ✓ Warning ≤ Warninglogger.info "not logged" // ✗ Info > WarningChild loggers
Section titled “Child loggers”logger.Child(prefix) creates a logger that prepends [prefix] to every message:
let db1 = logger.Child("db")let cache = logger.Child("cache")
db1.info "connected" // → [db] connectedcache.warning "cache miss" // → [cache] cache missChildren can be nested — prefixes are concatenated in order:
let db2 = logger.Child("db")let query = db.Child("query")
query.info "SELECT *" // → [db][query] SELECT *query.error "timeout" // → [db][query] timeoutCustom sinks
Section titled “Custom sinks”A Sink is a Severity -> string -> unit function, so any output target works:
let messages = ResizeArray<string>()
let collectingSink: Sink = fun severity msg -> messages.Add($"[{severity}] {msg}")
let myLogger = Parchment.Create(collectingSink)Sinks can be added or removed at runtime with logger.Add(sink) and logger.Remove(sink).