slog icon indicating copy to clipboard operation
slog copied to clipboard

Make it possible to Clone Records?

Open tomaka opened this issue 4 years ago • 1 comments

At the moment, it is not possible to clone the Record struct. Cloning the Record would be very useful in order to write a Drain that for example sends the log to a background thread through a channel for later processing.

The slog-async crate actually does what I described (send the record through a channel), but a good chunk of its source code consists in exactly that: cloning the Record.

Should the record cloning code not be moved to slog?

tomaka avatar Jul 31 '19 07:07 tomaka

Hmmmm.... That's a good point. I haven't thought about it this way (that slog-async is effectively doing Clone. I guess there's probably just one way to do it, so it could be a part of slog core.

:+1: from me. If you can submit a PR and go through the effort of making sure no backward compat etc. has been broken, then I'm happy to land such a thing (and potentially, but not requried a change in slog-async to use it).

dpc avatar Aug 03 '19 03:08 dpc