Skip to the content.

Debug

Structured logging and lightweight metrics.

local logger = Debug.Logger.new("Shop", { Level = "Info" })
logger:Info("Purchase", { Player = player.Name, Item = "Sword" })
--> [Shop] INFO Purchase Item=Sword Player=Player1

logger:Debug(function() return expensiveDump() end) -- only built when Debug is enabled

Logger

Member Description
Debug.Logger.new(name, { Level?, Sink? }?)  
logger:Trace/Debug/Info/Warn/Error(message, fields?) message is a string or a function that returns one
logger:SetLevel(level) / logger:GetLevel() / logger:IsEnabled(level)  
logger:Child(name) Named "Parent/name", with the same level and sink
Debug.format(record) The default line format

Metrics

Member Description
Debug.Metrics.new({ Enabled? }?)  
metrics:Increment(name, amount?) Counter
metrics:Observe(name, value) Tracks count, sum, min and max
metrics:Time(name, fn, ...) Runs fn, records its duration in milliseconds (also shown in the MicroProfiler) and returns its results. Errors are re-raised
metrics:Snapshot() { Counters, Observations = { [name] = { Count, Sum, Min, Max, Mean } } }
metrics:Reset() / metrics:SetEnabled(bool) When disabled, every call is a no-op
Debug.getMemoryKB() The current Luau heap size

There’s no global logger or registry. Pass loggers and metrics to the code that needs them, for example through a Core context or a Network Logger option.