Log API
ptool.log exposes level-based terminal logging helpers under both
ptool.log and p.log.
Every log call renders a line in this format:
[2026-04-30 14:54:56] INFO message text
Behavior:
- The timestamp uses local time in
YYYY-MM-DD HH:MM:SSformat. - The level label uses the full names
TRACE,DEBUG,INFO,WARN, andERROR. - Colored output is enabled automatically when
ptoolis writing to a terminal. ptool.log.error(...)writes tostderr. Other levels write tostdout.- Multiple arguments are joined with spaces. Non-string values are rendered in a single-line inspected form.
ptool.log.trace
v0.4.0- Introduced.
ptool.log.trace(...)
Writes a trace-level log line.
ptool.log.debug
v0.4.0- Introduced.
ptool.log.debug(...)
Writes a debug-level log line.
ptool.log.info
v0.4.0- Introduced.
ptool.log.info(...)
Writes an info-level log line.
ptool.log.warn
v0.4.0- Introduced.
ptool.log.warn(...)
Writes a warning-level log line.
ptool.log.error
v0.4.0- Introduced.
ptool.log.error(...)
Writes an error-level log line to stderr.
Example:
p.log.info("hello", { answer = 42 })
p.log.warn("careful")
p.log.error("boom")
Example output:
[2026-04-30 14:54:56] INFO hello { answer = 42 }
[2026-04-30 14:54:56] WARN careful
[2026-04-30 14:54:56] ERROR boom