Skip to content

Commit

Permalink
Do not use named logger interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dekiel committed Oct 11, 2024
1 parent 1aeed8e commit 6623c46
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
17 changes: 1 addition & 16 deletions cmd/image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ type options struct {
type Logger interface {
logging.StructuredLoggerInterface
logging.WithLoggerInterface
logging.NamedLoggerInterface
}

// parseVariable returns a build-arg.
Expand Down Expand Up @@ -664,7 +663,7 @@ func getTags(logger Logger, pr, sha string, templates []tags.Tag) ([]tags.Tag, e
logger.Debugw("commit sha is set, adding tagger option", "commit_sha", sha)
}

taggerOptions = append(taggerOptions, tags.WithLogger(logger.Named("tagger")))
taggerOptions = append(taggerOptions, tags.WithLogger(logger))
logger.Debugw("added logger to tagger options")
// build a tag from commit SHA
tagger, err := tags.NewTagger(logger, templates, taggerOptions...)
Expand Down Expand Up @@ -857,7 +856,6 @@ func main() {
log.Fatalf("Failed to initialize logger: %s", err)
}
o.logger = zapLogger.Sugar()
o.logger.Named("main")

// If running inside some CI system, determine which system is used
if o.isCI {
Expand Down Expand Up @@ -999,19 +997,6 @@ func tagsAsJSON(parsedTags []tags.Tag) ([]byte, error) {
return jsonTags, err
}

// func getEnvs(logger Logger, o options, dockerfileDirPath string) (map[string]string, error) {
// logger.Debugw("starting loading environment variables from file")
// logger.Debugw("Loading environment variables from env file", "envFile", o.envFile, "dockerfileDirPath", dockerfileDirPath)
// envs, err := loadEnv(o.logger, os.DirFS(dockerfileDirPath), o.envFile)
// if err != nil {
// return nil, fmt.Errorf("failed to load env file: %s", err)
// }
// if envs != nil {
// o.logger.Debugw("Environment variables loaded from env file", "envs", envs)
// }
// return envs, nil
// }

func parseTags(logger Logger, o options) ([]tags.Tag, error) {
logger.Debugw("starting to parse tags")
var (
Expand Down
4 changes: 0 additions & 4 deletions pkg/logging/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ type WithLoggerInterface interface {
With(args ...interface{}) *zap.SugaredLogger
}

type NamedLoggerInterface interface {
Named(name string) *zap.SugaredLogger
}

// Logger is an interface to interact with Google logging.
// TODO: this should be replaced by extending LoggerInterface
type Logger interface {
Expand Down

0 comments on commit 6623c46

Please sign in to comment.