Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Workflow Dependencies and Logging Configuration Improvements #896

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/nancy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up git repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
with:
go-version: '1.23'

- name: Ensure dependencies are up to date
run: go mod tidy

- name: Write go.list
run: |
go list -json -deps ./... | jq 'select(. | tostring | test("helm|apiserver"; "i") | not)' > go.list
Expand Down
11 changes: 5 additions & 6 deletions logging/logutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func (cfg *LogConfig) ConfigureLogger() (Logger, error) {
var err error
var fileHandler slog.Handler
var stdoutHandler slog.Handler

opts := &slog.HandlerOptions{
Level: cfg.Level,
}
Expand All @@ -113,11 +112,14 @@ func (cfg *LogConfig) ConfigureLogger() (Logger, error) {
fileHandler = slog.NewJSONHandler(logFile, opts)
}

if cfg.OutputType == ColorOutput {
switch cfg.OutputType {
case ColorOutput:
prettyOpts := PrettyHandlerOptions{SlogOpts: *opts}
stdoutHandler = NewPrettyHandler(os.Stdout, prettyOpts, cfg.OutputType)
} else {
case JSONOutput:
stdoutHandler = slog.NewJSONHandler(os.Stdout, opts)
default: // PlainOutput
stdoutHandler = slog.NewTextHandler(os.Stdout, opts)
}

var handlers []slog.Handler
Expand All @@ -127,11 +129,9 @@ func (cfg *LogConfig) ConfigureLogger() (Logger, error) {
if stdoutHandler != nil {
handlers = append(handlers, stdoutHandler)
}

if len(handlers) == 0 {
return nil, fmt.Errorf("no valid handlers available for logger")
}

multiHandler := slog.New(slogmulti.Fanout(handlers...))
var logger Logger
if cfg.OutputType == ColorOutput {
Expand All @@ -147,7 +147,6 @@ func (cfg *LogConfig) ConfigureLogger() (Logger, error) {
Logger: multiHandler,
}
}

return logger, nil
}

Expand Down
Loading