JSON log
GitHubStructured JSON logger with info, error, and elapsed-time helpers.
Installation
bash
pnpm dlx shadcn@latest add @cs/jsonlogUsage
tsx
import { jsonlog } from "@/lib/cs/jsonlog"tsx
jsonlog.info("user.create", "User created", { userId: 123 })API Reference
jsonlog
Writes structured JSON log entries and measures named operations.
Methods
tsx
jsonlog.info(source: string, message: string, data?: unknown): voidWrites an informational structured log entry.
tsx
jsonlog.error(source: string, message: string, data?: unknown): voidWrites an error structured log entry.
tsx
jsonlog.timer(source: string, message: string, data?: object): voidCreates a named operation timer that can record multiple elapsed intervals.