Skip to content

Commit

Permalink
Add support for Next 14
Browse files Browse the repository at this point in the history
This fixes #22.
  • Loading branch information
atkinchris committed Feb 23, 2024
1 parent 2bfeff8 commit e78a24a
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 185 deletions.
9 changes: 8 additions & 1 deletion lib/patches/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ const getPinoMethod = nextMethod => {
}
}

const cachePath = require.resolve('next/dist/build/output/log')
const cacheObject = require.cache[cachePath]

// This is required to forcibly redefine all properties on the logger.
// From Next 13 and onwards they're defined as non-configurable, preventing them from being patched.
cacheObject.exports = { ...cacheObject.exports }

Object.keys(nextLogger.prefixes).forEach(method => {
nextLogger[method] = getPinoMethod(method)
Object.defineProperty(cacheObject.exports, method, { value: getPinoMethod(method) })
})
Loading

0 comments on commit e78a24a

Please sign in to comment.