I would like to use Scrolls as a single logging pipe, but what I need to do is also have a way to capture that data via another (additional) mechanism than the STDOUT stream, for instance, a small class I wrote to store logs directly into Postgres. What would solve this nicely would be to register a hook with scrolls that is invoked when something is written to the logs:
Scrolls.hook(lambda { |data| MyClass.log(data) })
Better yet, we can use the Rack approach and have these hooks respond to #call, allowing something like:
Scrolls.hook MyClass
Scrolls.hook MyClass.new
I'd recommend that, for convenience, this method can also take a block that is automatically treated as a lambda function:
Scroll.hook { |data| MyClass.log(data) }
What do you think?
I would like to use Scrolls as a single logging pipe, but what I need to do is also have a way to capture that data via another (additional) mechanism than the
STDOUTstream, for instance, a small class I wrote to store logs directly into Postgres. What would solve this nicely would be to register a hook with scrolls that is invoked when something is written to the logs:Better yet, we can use the Rack approach and have these hooks respond to
#call, allowing something like:I'd recommend that, for convenience, this method can also take a block that is automatically treated as a lambda function:
What do you think?