deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

suggestion: rework `std/log` to use Streams API

Open iuioiua opened this issue 1 year ago • 2 comments

std/log is the last of the sub-modules that uses the deprecated Writer (i.e. Deno.Writer) interface. It should use WritableStream instead.

Related:

  • https://github.com/denoland/deno/pull/21465
  • https://github.com/denoland/deno_std/issues/1986

iuioiua avatar Dec 07 '23 05:12 iuioiua

I'm having a go at this.

It looks like moving to the Streams API causes some of the handler methods to become async, this might introduce complexities around what happens if a log comes in mid flush as operations are no longer atomic, especially so for the RotatingFileHandler.

Would you mind if I submit a WIP PR to see if I'm on the right track? I might need to implement a queue to buffer the buffer.

syhol avatar Dec 15 '23 22:12 syhol

That's great to hear! I've looked at your PR, and it seems like you're on the right track for now. Please let us know if you have any questions.

iuioiua avatar Dec 17 '23 20:12 iuioiua

An alternative was provided in #4021 that used Deno.FsFile.writeSync() and removed the dependency on Deno.Writer. Thank you for solving this, @syhol!

iuioiua avatar Dec 28 '23 03:12 iuioiua