Skip to content

Commit

Permalink
Add GUAC Version to Logs (#1856)
Browse files Browse the repository at this point in the history
- Added GUAC version to logs using a child logger.
- Version info comes from `pkg/version/version.go`, set during build by GoReleaser from the Makefile.

Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
  • Loading branch information
nathannaveen committed Apr 22, 2024
1 parent 3f124e3 commit c0e35bf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/logging/logger.go
Expand Up @@ -18,6 +18,7 @@ package logging
import (
"context"
"fmt"
"github.com/guacsec/guac/pkg/version"
"strings"

"go.uber.org/zap"
Expand All @@ -41,6 +42,7 @@ const (
Fatal LogLevel = "fatal"
ChildLoggerKey contextKey = "childLogger"
DocumentHash = "documentHash"
guacVersion = "guac-version"
)

type loggerKey struct{}
Expand All @@ -67,7 +69,7 @@ func InitLogger(level LogLevel) {
_ = zapLogger.Sync()
}()

logger = zapLogger.Sugar()
logger = zapLogger.Sugar().With(guacVersion, version.Version)

if levelErr != nil {
logger.Infof("Invalid log level %s: ", level, levelErr)
Expand Down

0 comments on commit c0e35bf

Please sign in to comment.