-
Notifications
You must be signed in to change notification settings - Fork 9
Description
You library work fine as i need (used to authentificate by using kerberos to remote proxy)....
but i've seen you not expose explicitly a way to configure the logging library.
i found in your code that you use debuf globale function that usr go lang log module in https://github.com/aus/proxyplease/blob/master/debug.go.
i've seen that you have SetDebugf that permit to overide this function to use another logger library...
but this function use global logger...
i used like that:
package main
import (
"context"
"fmt"
"strings"
"github.com/aus/proxyplease"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var l *zap.SugaredLogger
func main() {
config := zap.NewDevelopmentConfig()
config.EncoderConfig.TimeKey = "timestamp"
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
// set proxyplease globale logger
l = proxyServer.logger.Sugar()
// overide the debugf fonction of proxyplease
proxyplease.SetDebugf(func(format string, a ...interface{}) {
l.Debugf("proxyplease."+format, a...)
})
}can be added to the documentation in the readme.
but is not a good option in multithread/goroutine context... is preferable to transmit the logger by truct context...
while be a good improvement of you library to permit to store logger in Proxy config struct and use it every wherein the code.
you can use generic type slog for that, in that way we can use what i whant logger, zap or fastlog beceause they have there own slog implementation...
sample with zap:
https://github.com/samber/slog-zap