Skip to content

Commit

Permalink
Merge branch 'main' into export-setup-message
Browse files Browse the repository at this point in the history
* main:
  chore(deps): bump golang.org/x/term from 0.25.0 to 0.26.0 (zarf-dev#3220)
  chore(deps): bump goreleaser/goreleaser-action from 6.0.0 to 6.1.0 (zarf-dev#3216)
  chore: true up logger comments and minor refactors (zarf-dev#3215)
  chore(deps): bump golang.org/x/sync from 0.8.0 to 0.9.0 (zarf-dev#3218)
  • Loading branch information
catsby committed Nov 8, 2024
2 parents 8c2862b + 36b779f commit b27a093
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ jobs:

# Create the GitHub release notes, upload artifact backups to S3, publish homebrew recipe
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
with:
distribution: goreleaser
version: "~> v2"
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ require (
github.com/stretchr/testify v1.9.0
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/crypto v0.28.0
golang.org/x/sync v0.8.0
golang.org/x/term v0.25.0
golang.org/x/sync v0.9.0
golang.org/x/term v0.26.0
helm.sh/helm/v3 v3.16.2
k8s.io/api v0.31.2
k8s.io/apimachinery v0.31.2
Expand Down Expand Up @@ -526,7 +526,7 @@ require (
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1976,8 +1976,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -2082,8 +2082,8 @@ golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand All @@ -2096,8 +2096,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
20 changes: 10 additions & 10 deletions src/pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ func ConfigDefault() Config {

// New takes a Config and returns a validated logger.
func New(cfg Config) (*slog.Logger, error) {
var handler slog.Handler
opts := slog.HandlerOptions{}

// Use default destination if none
if cfg.Destination == nil {
cfg.Destination = DestinationDefault
Expand All @@ -167,8 +164,12 @@ func New(cfg Config) (*slog.Logger, error) {
if !validLevels[cfg.Level] {
return nil, fmt.Errorf("unsupported log level: %d", cfg.Level)
}
opts.Level = slog.Level(cfg.Level)

opts := slog.HandlerOptions{
Level: slog.Level(cfg.Level),
}

var handler slog.Handler
switch cfg.Format.ToLower() {
case FormatText:
handler = console.NewHandler(cfg.Destination, &console.HandlerOptions{
Expand All @@ -195,14 +196,13 @@ func New(cfg Config) (*slog.Logger, error) {
return nil, fmt.Errorf("unsupported log format: %s", cfg.Format)
}

log := slog.New(handler)
return log, nil
return slog.New(handler), nil
}

// ctxKey provides a location to store a logger in a context.
type ctxKey struct{}

// defaultCtxKey provides a default key if one is not passed into From.
// defaultCtxKey provides a key instance to get a logger from context
var defaultCtxKey = ctxKey{}

// WithContext takes a context.Context and a *slog.Logger, storing it on the key
Expand Down Expand Up @@ -239,12 +239,12 @@ func Enabled(ctx context.Context) bool {
func From(ctx context.Context) *slog.Logger {
// Check that we have a ctx
if ctx == nil {
return newEmpty()
return newDiscard()
}
// Grab value from key
log := ctx.Value(defaultCtxKey)
if log == nil {
return newEmpty()
return newDiscard()
}

// Ensure our value is a *slog.Logger before we cast.
Expand All @@ -258,7 +258,7 @@ func From(ctx context.Context) *slog.Logger {
}

// newDiscard returns a logger without any settings that goes to io.Discard
func newEmpty() *slog.Logger {
func newDiscard() *slog.Logger {
h := slog.NewTextHandler(DestinationNone, &slog.HandlerOptions{})
return slog.New(h)
}
Expand Down

0 comments on commit b27a093

Please sign in to comment.