This repository was archived by the owner on Jun 9, 2025. It is now read-only.
feat: support custom raw logger #461
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which problem is this pull request solving?
This PR proposes two changes to the API of the recently-added system logger:
Remove the
NETLIFY_DEVandNETLIFY_ENABLE_SYSTEM_LOGGINGenvironment variables in favour of a newSilentlog level. If we want to silence the logger from the CLI or any other consumer applications, we should let them configure that behaviour themselves rather than making the logger rely on their internals.Moreover, this lets the CLI more easily configure this behaviour conditionally — e.g. show system logs if the
--debugflag has been used, which is what we do currently with edge functions.Allow consumers to specify a custom raw logger that replaces the default
globalThis.consolemethods. We can use this to plug this logger into the system logger that we expose to build plugins, where we want to callutils.systemLogand notconsole.logon the resulting payload.I'm exporting the underlying class (which I've renamed to
StructuredLogger, because I think it's more accurate), which accepts a raw logger in the constructor.