Skip to content
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
4 changes: 2 additions & 2 deletions deployment/clouddeploy/gke-workers/base/gitter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ spec:
env:
- name: GOMEMLIMIT
value: "100GiB"
- name: DEBUG_LOG
value: "true"
- name: LOG_LEVEL
value: "debug"
volumeMounts:
- mountPath: /work
name: disk-data
Expand Down
14 changes: 12 additions & 2 deletions go/logger/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"sync"

"cloud.google.com/go/errorreporting"
Expand Down Expand Up @@ -119,8 +120,17 @@ func initTracing(ctx context.Context, projectID, serviceName string) {

func cloudHandlerOptions() *slog.HandlerOptions {
level := slog.LevelInfo
if os.Getenv("DEBUG_LOG") != "" {
level = slog.LevelDebug
if lvl := os.Getenv("LOG_LEVEL"); lvl != "" {
switch strings.ToLower(lvl) {
case "debug":
level = slog.LevelDebug
case "info":
level = slog.LevelInfo
case "warn":
level = slog.LevelWarn
case "error":
level = slog.LevelError
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a default for e.g. a typo

@michaelkedar michaelkedar Feb 19, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's set to info before the switch

}

return &slog.HandlerOptions{
Expand Down
27 changes: 23 additions & 4 deletions go/logger/localhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"log/slog"
"os"
"strings"

"github.com/charmbracelet/lipgloss"
Expand All @@ -26,17 +27,35 @@ var (
)

type localHandler struct {
w io.Writer
w io.Writer
level slog.Level
}

var _ slog.Handler = (*localHandler)(nil)

func newLocalHandler(w io.Writer) *localHandler {
level := slog.LevelInfo
if lvl := os.Getenv("LOG_LEVEL"); lvl != "" {
switch strings.ToLower(lvl) {
case "debug":
level = slog.LevelDebug
case "info":
level = slog.LevelInfo
case "warn":
level = slog.LevelWarn
case "error":
level = slog.LevelError
}
Comment thread
michaelkedar marked this conversation as resolved.
}

return &localHandler{
w: w,
w: w,
level: level,
}
}

func (h *localHandler) Enabled(_ context.Context, _ slog.Level) bool {
return true
func (h *localHandler) Enabled(_ context.Context, level slog.Level) bool {
return level >= h.level
}

func (h *localHandler) Handle(_ context.Context, r slog.Record) error {
Expand Down
Loading