Logging
Logging
Section titled “Logging”Structured logging with debug, info, warn, and error levels.
Loading
Section titled “Loading”local logger = require("logger")Log Levels
Section titled “Log Levels”logger:debug("message", {key = "value"})| Parameter | Type | Description |
|---|---|---|
message | string | Log message |
fields | table? | Contextual key-value pairs |
logger:info("message", {key = "value"})| Parameter | Type | Description |
|---|---|---|
message | string | Log message |
fields | table? | Contextual key-value pairs |
logger:warn("message", {key = "value"})| Parameter | Type | Description |
|---|---|---|
message | string | Log message |
fields | table? | Contextual key-value pairs |
logger:error("message", {key = "value"})| Parameter | Type | Description |
|---|---|---|
message | string | Log message |
fields | table? | Contextual key-value pairs |
Logger Customization
Section titled “Logger Customization”With Fields
Section titled “With Fields”Create a child logger with persistent fields.
local child = logger:with({request_id = id})child:info("message")| Parameter | Type | Description |
|---|---|---|
fields | table | Fields to attach to all logs |
Returns: Logger
Named Logger
Section titled “Named Logger”Create a named child logger.
local named = logger:named("auth")named:info("message")| Parameter | Type | Description |
|---|---|---|
name | string | Logger name |
Returns: Logger
Errors
Section titled “Errors”| Condition | Kind | Retryable |
|---|---|---|
| Empty name string | errors.INVALID | no |
See Error Handling for working with errors.