Skip to content

Commit

Permalink
refactor(all): use log/slog instead of golang.org/x/exp/slog
Browse files Browse the repository at this point in the history
  • Loading branch information
ijsong committed Nov 16, 2023
1 parent 0f02a73 commit fc17011
Show file tree
Hide file tree
Showing 29 changed files with 14 additions and 3,902 deletions.
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ linters-settings:
deny:
- pkg: golang.org/x/net/context
desc: Should be replaced by standard lib context package
- pkg: golang.org/x/exp/slog
desc: Should be replaced by standard lib slog package
- pkg: golang.org/x/exp/slices
desc: Should be replaced by standard lib slices package
godot:
exclude:
- "^ TODO"
Expand Down
2 changes: 1 addition & 1 deletion cmd/benchmark/save_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"encoding/json"
"fmt"
"io"
"log/slog"
"os"
"time"

"github.com/urfave/cli/v2"
"golang.org/x/exp/slog"

"github.com/kakao/varlog/internal/benchmark"
"github.com/kakao/varlog/internal/benchmark/database"
Expand Down
2 changes: 1 addition & 1 deletion cmd/benchmark/serve_command.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package main

import (
"log/slog"
"os"
"os/signal"
"sync"
"syscall"

"github.com/urfave/cli/v2"
"golang.org/x/exp/slog"

"github.com/kakao/varlog/internal/benchmark/server"
)
Expand Down
9 changes: 5 additions & 4 deletions internal/benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package benchmark
import (
"context"
"fmt"
"log/slog"
"os"
"os/signal"
"sync"
"syscall"
"time"

"go.uber.org/multierr"
"golang.org/x/exp/slog"

"golang.org/x/sync/errgroup"
)

Expand All @@ -28,9 +29,9 @@ func New(opts ...Option) (bm *Benchmark, err error) {
return nil, err
}

logger := slog.New(slog.HandlerOptions{
Level: slog.InfoLevel.Level(),
}.NewTextHandler(os.Stdout))
logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
Level: slog.LevelInfo,
}))
slog.SetDefault(logger)

bm = &Benchmark{
Expand Down
5 changes: 2 additions & 3 deletions internal/benchmark/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"context"
"errors"
"fmt"
"log/slog"
"time"

"go.uber.org/multierr"
"go.uber.org/zap"
"golang.org/x/exp/slog"
"golang.org/x/sync/errgroup"

"github.com/kakao/varlog/pkg/types"
Expand Down Expand Up @@ -271,7 +270,7 @@ func (loader *Loader) subscribeLoop(ctx context.Context, c varlog.Log) error {
close(stop)
return
}
loader.logger.Debug("subscribed", zap.String("log", logEntry.String()))
loader.logger.Debug("subscribed", slog.String("log", logEntry.String()))
sm.logs++
sm.bytes += int64(len(logEntry.Data))
if loader.metrics.ReportSubscribeMetrics(sm) {
Expand Down
2 changes: 1 addition & 1 deletion internal/benchmark/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"errors"
"fmt"
"html/template"
"log/slog"
"net"
"net/http"
"sort"
"strconv"
"strings"

_ "github.com/lib/pq"
"golang.org/x/exp/slog"

"github.com/kakao/varlog/internal/benchmark/model/macro/metric"
"github.com/kakao/varlog/internal/benchmark/model/macro/result"
Expand Down
50 changes: 0 additions & 50 deletions vendor/golang.org/x/exp/constraints/constraints.go

This file was deleted.

Loading

0 comments on commit fc17011

Please sign in to comment.