Skip to content

API Documentation

SillyKitr edited this page Jun 20, 2026 · 1 revision

Important

This current wiki is in heavy WIP! Expect missing stuff..

You may temporarily check the source code for the API documentation, it's quite easy to read.

Welcome to the kitr/logger wiki!

You will find most API documentation in here.

API

Creating a Logger

local log = Logger.new({
    name = "Server",        -- optional, shown in brackets
    level = "debug",        -- "trace" | "debug" | "info" | "warn" | "error" | "fatal"
    colors = true,          -- enable ANSI color output
    timestamps = true,      -- prepend UTC timestamps
    sink = function(line, level)  -- custom output (default: print)
        io.write(line, "\n")
    end,
})

Logging

log:trace("verbose detail")
log:debug("debug info")
log:info("general info")
log:warn("warning")
log:error("error")
log:fatal("fatal error")

Multiple arguments are space-joined automatically.

Level Management

log:getLevel()               -- returns current level name
log:setLevel("warn")         -- change level at runtime
log:isLevelEnabled("debug")  -- check if a level would be logged

Default Logger (Module-Level)

Use the module directly as a singleton:

Logger.configure({ name = "App", level = "warn" })
Logger.info("hidden")        -- filtered out
Logger.warn("visible")
Logger.getLevel()            -- "warn"
Logger.setLevel("trace")

Configuration Options

Option Type Default Description
name string? nil Logger name shown in brackets
level LevelName? "info" Minimum level to log
colors boolean? false Enable ANSI color codes
timestamps boolean? false Prepend ISO 8601 UTC timestamps
sink ((string, LevelName) -> ())? print Custom output function

Levels

Level Value Color
trace 10 Gray
debug 20 Light blue
info 30 Green
warn 40 Yellow
error 50 Bold red
fatal 60 Purple

Clone this wiki locally