use a defined logger

this should avoid issues with the embedded
client also attempting to use the same global logger
This commit is contained in:
Alisdair MacLeod
2026-01-30 16:31:32 +00:00
parent 5345d716ee
commit 3a6f364b03
9 changed files with 115 additions and 47 deletions

View File

@@ -16,11 +16,16 @@ type gRPCClient interface {
type Logger struct {
client gRPCClient
logger *log.Logger
}
func NewLogger(client gRPCClient) *Logger {
func NewLogger(client gRPCClient, logger *log.Logger) *Logger {
if logger == nil {
logger = log.StandardLogger()
}
return &Logger{
client: client,
logger: logger,
}
}
@@ -68,7 +73,7 @@ func (l *Logger) log(ctx context.Context, entry logEntry) {
},
}); err != nil {
// If it fails to send on the gRPC connection, then at least log it to the error log.
log.WithFields(log.Fields{
l.logger.WithFields(log.Fields{
"service_id": entry.ServiceId,
"host": entry.Host,
"path": entry.Path,