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

refactor(all): use log/slog instead of golang.org/x/exp/slog #633

Merged
merged 1 commit into from
Jan 2, 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
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