[GODRIVER-2891] options.LogLevel is not 1-1 with LogSink Created: 06/Jul/23 Updated: 28/Oct/23 Resolved: 20/Jul/23 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.12.1 |
| Type: | Improvement | Priority: | Unknown |
| Reporter: | Preston Vasquez | Assignee: | Preston Vasquez |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Documentation Changes: | Not Needed |
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
| Description |
|
The level value returned by the Info function of a LogSink implementation will always be 1 less than the analogous options.LogLevel values. For example, options.LogLevelInfo is set to logger.LevelInfo, which is the 1 enumeration. The internal logger "Print" method will return 0 (logger.LevelInfo - logger.DiffToInfo). In general, the internal "Print" method returns the difference between the internal level and the "DiffToInfo" constant. This is to ensure that "Info" is the 0th "level", so as to sync the LogSink with the go-logr/logr library:
Here is a gist that illustrates this problem. There are two notable solutions to this problem: (1) offset the stable api levels:
This would be a breaking change since users may already be offsetting these levels in custom LogSink implementations. (2) create a function that converts the level returned by the log sink to the stable API level. |
| Comments |
| Comment by Githook User [ 01/Aug/23 ] |
|
Author: {'name': 'Preston Vasquez', 'email': 'prestonvasquez@icloud.com', 'username': 'prestonvasquez'}Message: Co-authored-by: Steven Silvester <steven.silvester@ieee.org> |
| Comment by Githook User [ 20/Jul/23 ] |
|
Author: {'name': 'Preston Vasquez', 'email': 'prestonvasquez@icloud.com', 'username': 'prestonvasquez'}Message: Co-authored-by: Steven Silvester <steven.silvester@ieee.org> |