Skip to content

chore(log): rework std/log to work without deprecated Deno.Writer - #4021

Merged
iuioiua merged 4 commits into
denoland:mainfrom
syhol:synchronous-log-streams-api
Dec 28, 2023
Merged

chore(log): rework std/log to work without deprecated Deno.Writer#4021
iuioiua merged 4 commits into
denoland:mainfrom
syhol:synchronous-log-streams-api

Conversation

@syhol

@syhol syhol commented Dec 24, 2023

Copy link
Copy Markdown
Contributor

Attempting to solve #3907

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

Previous attempt of #3969 was trying to use std/streams/buffer.ts and the streams API, but moving to async flushes resulted in potentially lost logs.

Now just solving with a Uint8Array and a ArrayBuffer and a number pointer.

@syhol
syhol requested a review from kt3k as a code owner December 24, 2023 01:27
@github-actions github-actions Bot added the log label Dec 24, 2023
Comment thread log/handlers.ts
Comment thread log/handlers.ts Outdated
Comment thread log/handlers.ts Outdated
@syhol

syhol commented Dec 28, 2023 via email

Copy link
Copy Markdown
Contributor Author

@iuioiua

iuioiua commented Dec 28, 2023

Copy link
Copy Markdown
Contributor

Hash prefix please 🙂

syhol and others added 2 commits December 28, 2023 01:21
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
@syhol

syhol commented Dec 28, 2023

Copy link
Copy Markdown
Contributor Author

All suggestions applied 🙏 ready for another review 🎉

@iuioiua iuioiua changed the title chore(log): rework std/log to no longer depend on the deprecated Writer chore(log): rework std/log to work without deprecated Deno.Writer Dec 28, 2023

@iuioiua iuioiua left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thank you for this.

@dvv

dvv commented Feb 28, 2024

Copy link
Copy Markdown

Hi!

With this attempt to log circa 4096 octets message just dumps the process.

import { RotatingFileHandler } from "https://deno.land/std@0.217.0/log/mod.ts"

const logger = new RotatingFileHandler(
  "DEBUG",
  {
    filename: "/tmp/123",
    maxBytes: 4000000,
    maxBackupCount: 10,
  },
)
logger.log("x".repeat(4096))
error: Uncaught (in promise) RangeError: offset is out of bounds
    this._buf.set(bytes, this._pointer);
              ^
    at Uint8Array.set (<anonymous>)
    at RotatingFileHandler.log (https://deno.land/std@0.217.0/log/file_handler.ts:79:15)
    at RotatingFileHandler.log (https://deno.land/std@0.217.0/log/rotating_file_handler.ts:106:11)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants