Add WithDefaultPrintLevel option to configure default log level for Print methods #40
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.
Problem
When Echo framework uses its internal logging methods (such as for server startup messages), it calls the
PrintandPrintfmethods without specifying a log level. This results in logs showing???or-instead of a proper log level:This happens because the current implementation always uses
zerolog.NoLevelwith a hardcoded level string of"-"for these methods.Solution
This PR adds a new configuration option
WithDefaultPrintLevel(level log.Lvl)that allows users to configure a default log level for Echo's Print methods. When configured, these methods will use the specified level instead of showing???.Usage
Result:
Implementation Details
defaultPrintLevel *log.Lvlfield toOptionsandLoggerstructsWithDefaultPrintLevel(level log.Lvl)setter functionprintEvent()helper method to determine the appropriate zerolog eventPrint,Printf, andPrintjmethods to use the configurable levelWithDefaultPrintLevelis not specified, behavior remains exactly the same (backward compatible)Testing
Documentation
Updated README.md with:
This change is completely backward compatible and provides a clean solution to the "???" log level issue reported in the original issue.
Fixes #33
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.