Skip to content

struct Log::Emitter
inherits Struct

Helper DSL module for emitting log entries with data.

Methods

#emit(message : String, data : Metadata | Hash | NamedTuple) : Entry

View source

#emit(message : String) : Entry

Emits a logs entry with a message, and data attached to

Log.info &.emit("Program started")                         # No data, same as Log.info { "Program started" }
Log.info &.emit("User logged in", user_id: 42)             # With entry data
Log.info &.emit(action: "Logged in", user_id: 42)          # Empty string message, only data
Log.error exception: ex, &.emit("Oops", account: {id: 42}) # With data and exception
View source

#emit(data : Metadata | Hash | NamedTuple) : Entry

View source

#emit(message : String, **kwargs) : Entry

View source

#emit(**kwargs) : Entry

View source