3 ms·
I think the author is on the cusp of the right idea but misses it with the new implementation — the only meaningful change is switching fixed strings interpolat
by Spivak 5y ago
I think the author is on the cusp of the right idea but misses it with the new implementation — the only meaningful change is switching fixed strings interpolated with data to fixed classes parametrized with data. It’s not nothing, but it’s basically a funny way to do structured logging. Logging systems are already event streams with the ability for consumers modify, add supplementary data, and route output with strategies, formatters, etc etc.
What I would rather see is a new keyword that generalizes the concept of logging in it’s entirety — “emit $object.”
For discrete events it would be emit ThingHappened(), for logs it would be emit Log(), and for traces it would be emit OpenSpan() and emit CloseSpan(). You could collapse whole classes of libraries into a few emit calls and a single listener.