W3cubDocs

/Crystal

struct Log::Context

Defined in:

log/main.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(metadata : Metadata)Source

Instance Method Detail

def clearSource

Clears the current Fiber logging context.

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

def metadata : MetadataSource

def set(values)Source

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) }

def set(**kwargs)Source

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) }

© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/Log/Context.html