Console
class
Defined in src/logit/backends/console.cr:37
Backend that writes log events to the console (STDOUT).
Uses the Formatter::Human formatter by default, which produces colorized,
human-readable output suitable for development and debugging.
Basic Usage
Custom Configuration
# Use JSON formatter for console output
Logit.configure do |config|
config.console(
level: Logit::LogLevel::Info,
formatter: Logit::Formatter::JSON.new
)
end
Output Example (Human formatter)
Constructors
.new(name = "console", level = LogLevel::Info, formatter = Formatter::Human.new)
Creates a new console backend.
- name: Backend name for identification (default: "console")
- level: Minimum log level (default: Info)
- formatter: Output formatter (default: Human)
Instance Methods
#flush
Flushes the output buffer.
#io
The IO to write to (defaults to STDOUT).
#log(event : Event) : Nil
Logs an event to the console.