The one logging system for spel.
Every spel process — the CLI client, the background daemon, the browser
engine helpers — writes through this namespace, so all diagnostics land in
ONE place with ONE format instead of scattered println calls that vanish
into a redirected stdout.
Layout:
<tmpdir>/spel-<session>.log (also the file the
daemon subprocess appends its raw stdout/stderr to).<iso-ts> <LEVEL> [<component>] <message>.SPEL_LOG_LEVEL (debug|info|warn|error|off), or
SPEL_DEBUG=true for debug. Default: info.Read it back with spel logs (see read-lines, tail!).
The one logging system for spel. Every spel process — the CLI client, the background daemon, the browser engine helpers — writes through this namespace, so all diagnostics land in ONE place with ONE format instead of scattered `println` calls that vanish into a redirected stdout. Layout: - One log file per session: `<tmpdir>/spel-<session>.log` (also the file the daemon subprocess appends its raw stdout/stderr to). - One line format: `<iso-ts> <LEVEL> [<component>] <message>`. - One level threshold: `SPEL_LOG_LEVEL` (debug|info|warn|error|off), or `SPEL_DEBUG=true` for debug. Default: info. Read it back with `spel logs` (see `read-lines`, `tail!`).
(clear! session)Truncates a session's log file. Returns true when a file was cleared.
Truncates a session's log file. Returns true when a file was cleared.
(current-level)Returns the active threshold keyword.
Returns the active threshold keyword.
(debug! & parts)Logs a debug line. Parts are str-joined.
Logs a debug line. Parts are `str`-joined.
(enabled? level)True when level passes the active threshold.
True when `level` passes the active threshold.
(error! & parts)Logs an error line. Parts are str-joined.
Logs an error line. Parts are `str`-joined.
(exception! context e)Logs an exception with a context label at warn level. Used in cleanup paths where we continue despite errors but never swallow them silently.
Logs an exception with a context label at warn level. Used in cleanup paths where we continue despite errors but never swallow them silently.
(format-line ts level component message)Builds one canonical log line: <ts> <LEVEL> [<component>] <message>.
Pure — the single place the wire format is defined.
Builds one canonical log line: `<ts> <LEVEL> [<component>] <message>`. Pure — the single place the wire format is defined.
(info! & parts)Logs an info line. Parts are str-joined.
Logs an info line. Parts are `str`-joined.
(init! {:keys [session component level mirror file?]})Configures the logger for this process. Call once at startup.
Params:
opts - Map:
:session - String session name (default "default")
:component - String tag shown in every line, e.g. "cli" or "daemon"
:level - Keyword/String threshold; defaults to SPEL_LOG_LEVEL/SPEL_DEBUG
:mirror - Keyword/String level mirrored to stderr, or :off to never
mirror (the daemon uses :off — its stderr already appends to
the same log file, so mirroring would double every line)
:file? - Boolean, write to the session log file (default true)
Configures the logger for this process. Call once at startup.
Params:
`opts` - Map:
:session - String session name (default "default")
:component - String tag shown in every line, e.g. "cli" or "daemon"
:level - Keyword/String threshold; defaults to SPEL_LOG_LEVEL/SPEL_DEBUG
:mirror - Keyword/String level mirrored to stderr, or :off to never
mirror (the daemon uses :off — its stderr already appends to
the same log file, so mirroring would double every line)
:file? - Boolean, write to the session log file (default true)(log! level message)Logs message at level through the one sink. No-op below threshold.
Logs `message` at `level` through the one sink. No-op below threshold.
(log-exists? session)True when the session has a log file on disk.
True when the session has a log file on disk.
(log-file-path session)Returns the log file path for a session — spel's single log sink.
Returns the log file path for a session — spel's single log sink.
(parse-level x default-level)Parses a level name (string or keyword) into a level keyword.
Returns default-level when the input is blank or unrecognized.
Parses a level name (string or keyword) into a level keyword. Returns `default-level` when the input is blank or unrecognized.
(read-lines session {:keys [lines]})Returns the last n lines of a session's log (all of them when n is nil).
Returns an empty vector when there is no log file yet.
Returns the last `n` lines of a session's log (all of them when `n` is nil). Returns an empty vector when there is no log file yet.
(tail! session {:keys [lines poll-ms] :or {poll-ms 250}})Prints a session's log and then follows it, printing appended lines as they arrive. Blocks until interrupted.
Params:
session - String session name
opts - Map: :lines (initial tail size), :poll-ms (default 250)
Prints a session's log and then follows it, printing appended lines as they arrive. Blocks until interrupted. Params: `session` - String session name `opts` - Map: :lines (initial tail size), :poll-ms (default 250)
(timestamp instant)Formats an Instant as the log's fixed-width UTC timestamp.
Formats an Instant as the log's fixed-width UTC timestamp.
(warn! & parts)Logs a warning line. Parts are str-joined.
Logs a warning line. Parts are `str`-joined.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |