lavinmq icon indicating copy to clipboard operation
lavinmq copied to clipboard

Use Log#emit and Log::Metadata

Open carlhoerberg opened this issue 2 years ago • 2 comments

Saves Log instances and uses Metadata instead, repetetive but better than the alternative

carlhoerberg avatar Sep 13 '23 13:09 carlhoerberg

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

?

baelter avatar Sep 14 '23 05:09 baelter

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

?

The EntityLog here does that: https://github.com/cloudamqp/lavinmq/blob/logging-sources/src/lavinmq/logging.cr

spuun avatar Sep 14 '23 05:09 spuun

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.

carlhoerberg avatar Jun 21 '24 00:06 carlhoerberg