Skip to content

Log

The @std/log module provides simple leveled logging.

import log from "@std/log"
log.info("server started")

The supported levels are:

LevelPriority
DEBUG0
INFO1
WARN2
ERROR3

The default level is INFO.

Messages below the current level are ignored.

NameDescription
debug(...)Writes a debug message.
info(...)Writes an info message.
warn(...)Writes a warning message.
error(...)Writes an error message.
setLevel(level)Sets the current log level.
import log from "@std/log"
log.debug("debug value:", 123)
log.info("user logged in")
log.warn("missing optional config")
log.error("request failed")

warn and error write to standard error. debug and info write to standard output.

Sets the minimum level to print.

import log from "@std/log"
log.setLevel("DEBUG")
log.debug("now debug logs are visible")

The level is case-insensitive internally because it is normalized to uppercase.

import log from "@std/log"
log.setLevel("warn")
log.info("hidden")
log.warn("visible")