Add a ParseLevel funtion for loglevel string conversion#21
Add a ParseLevel funtion for loglevel string conversion#21crooks wants to merge 3 commits intoMasterminds:mainfrom
Conversation
mattfarina
left a comment
There was a problem hiding this comment.
What is the use case for this function? The levels aren't used as part of the interface. Can you provide some insight into how this would be used?
log.go
Outdated
|
|
||
| // Atoi returns the loglevel integer associated with a common loglevel | ||
| // string representation. | ||
| func Atoi(loglevelStr string) (level int, err error) { |
There was a problem hiding this comment.
Instead of calling it Atoi can the function be named ParseLevel?
While the implementations of the levels are ints under the hood, the ints aren't really used as ints. Atoi is a common function name for a function that turns strings into ints. This is turning specific names into Levels.
With that in mind, can a new type be created for the Level and return that instead of an int.
There was a problem hiding this comment.
Hi Matt, thanks for the feedback. Regarding the use case for the function: My goal was to provide a means for translating the string-type loglevels usually specified in config files into the internal log-go loglevels. This could be done at the downstream implementation but, I think, the string representations of log levels are sufficiently standardised that the upstream library is the most logical place to host this function.
Signed-off-by: Steve Crook <steve@mixmin.net>
Changes suggested by upstream maintainer Matt Farina. Signed-off-by: Steve Crook <steve@mixmin.net>
This pull request adds an Atoi helper function. The function provides a conversion from the standard log-level string representations to the integer levels used in log-go.