Add verbose logging controlled by CACHED_MIDDLEWARE_FETCH_LOGGER environment variable#8
Merged
bookernath merged 2 commits intoSep 2, 2025
Conversation
…ronment variable Co-authored-by: bookernath <8922457+bookernath@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add verbose logging which can be enabled by a CACHED_MIDDLEWARE_FETCH_LOGGER=1 environment variable
Add verbose logging controlled by CACHED_MIDDLEWARE_FETCH_LOGGER environment variable
Sep 2, 2025
bookernath
marked this pull request as ready for review
September 2, 2025 23:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds comprehensive verbose logging to help developers debug and understand caching behavior in
cached-middleware-fetch-next. The logging can be enabled by setting theCACHED_MIDDLEWARE_FETCH_LOGGER=1environment variable.What's Added
Verbose Logging Function
verboseLog()utility that only outputs whenCACHED_MIDDLEWARE_FETCH_LOGGER=1[cached-middleware-fetch]prefix as existing error logs for consistencyComprehensive Logging Coverage
The verbose logging now provides detailed insights into:
Request Flow:
Cache Operations:
Storage and Performance:
Usage
Enable verbose logging by setting the environment variable:
export CACHED_MIDDLEWARE_FETCH_LOGGER=1Or in your application:
Benefits
Documentation
Updated README.md with a new "Debugging and Verbose Logging" section that explains:
This enhancement makes it much easier for developers to understand and debug caching behavior in their Next.js middleware implementations.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
jsonplaceholder.typicode.comnode test-verbose-logging.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.