Skip to content

struct Log::Context
inherits Struct

Class methods

.new(metadata : Metadata)

View source

Methods

#clear

Clears the current Fiber logging context.

Log.context.clear
Log.info { "message with empty context" }
View source

#metadata : Metadata

View source

#set(values)

Extends the current Fiber logging context.

Log.context.set a: 1
Log.context.set b: 2
Log.info { %q(message with a: 1, b: 2 context") }
h = {:c => "3"}
Log.context.set extra: h
Log.info { %q(message with a: 1, b: 2, extra: {"c" => "3"} context) }
h = {"c" => 3}
Log.context.set extra: h
Log.info { %q(message with a: 1, b: 2, extra: {"c" => 3} context) }
View source

#set(**kwargs)

Extends the current Fiber logging context.

Log.context.set a: 1
Log.context.set b: 2
Log.info { %q(message with a: 1, b: 2 context") }
h = {:c => "3"}
Log.context.set extra: h
Log.info { %q(message with a: 1, b: 2, extra: {"c" => "3"} context) }
h = {"c" => 3}
Log.context.set extra: h
Log.info { %q(message with a: 1, b: 2, extra: {"c" => 3} context) }
View source