log
.zn moduleStructured, leveled logging to stderr. import "log". A Logger holds a name and a minimum level; messages below the level are dropped. Output format: [LEVEL] [name] message. Levels: log.LEVEL_DEBUG (0), LEVEL_INFO (1), LEVEL_WARN (2), LEVEL_ERROR (3), LEVEL_FATAL (4), LEVEL_OFF (5).
log.new(name: string) => Loggerlog.set_level(logger, level: int)log.format_line(logger, level: int, msg) => stringlog.debug/info/warn/error(logger, msg: string)log.fatal(logger, msg: string)log.debugf/infof/warnf/errorf(logger, msg, fields: [string, string])log.fatalf(logger, msg, fields)
log.new(name: string) => Logger
Create a logger (default level INFO).
log.set_level(logger, level: int)
Set the minimum level.
log.format_line(logger, level: int, msg) => string
Build the formatted line (no I/O).
log.debug/info/warn/error(logger, msg: string)
Log at that level.
log.fatal(logger, msg: string)
Log at FATAL, then os.exit(1).
log.debugf/infof/warnf/errorf(logger, msg, fields: [string, string])
Log with key=value structured fields appended.
log.fatalf(logger, msg, fields)
Structured FATAL, then os.exit(1).
import "log"
lg := log.new("myapp")
log.set_level(lg, log.LEVEL_DEBUG)
log.info(lg, "server ready")
log.infof(lg, "request", {"method": "GET", "path": "/api"})