lavinmq
lavinmq copied to clipboard
Use Log#emit and Log::Metadata
Saves Log instances and uses Metadata instead, repetetive but better than the alternative
Can't we wrap this with our own Log, something like
class LavinMQ::Log < ::Log
property metadata
def debug
msg = yield
super.debug &.emit msg, metadata
end
...
end
Log = LavinMQ::Log.for(self)
Log.metadata = ...
Log.debug { "yada" }
?
Can't we wrap this with our own
Log, something likeclass LavinMQ::Log < ::Log property metadata def debug msg = yield super.debug &.emit msg, metadata end ... end Log = LavinMQ::Log.for(self) Log.metadata = ... Log.debug { "yada" }?
The EntityLog here does that: https://github.com/cloudamqp/lavinmq/blob/logging-sources/src/lavinmq/logging.cr
Getting rid of @log that we might think be a memory leak. And doesn't do any monkey patching of anything, uses the "native" way of logging metadata with Log.