Skip to content

Commit

Permalink
migrate to slog & go 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Aug 8, 2023
1 parent 864959c commit a06f865
Show file tree
Hide file tree
Showing 69 changed files with 387 additions and 345 deletions.
6 changes: 3 additions & 3 deletions _examples/application_commands/gateway/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -40,9 +41,8 @@ var (
)

func main() {
log.SetLevel(log.LevelInfo)
log.Info("starting example...")
log.Info("disgo version: ", disgo.Version)
slog.Info("starting example...")
slog.Info("disgo version", slog.String("version", disgo.Version))

client, err := disgo.New(token,
bot.WithDefaultGateway(),
Expand Down
6 changes: 3 additions & 3 deletions _examples/application_commands/http/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -43,9 +44,8 @@ var (
)

func main() {
log.SetLevel(log.LevelDebug)
log.Info("starting example...")
log.Info("disgo version: ", disgo.Version)
slog.Info("starting example...")
slog.Info("disgo version", slog.String("version", disgo.Version))

// use custom ed25519 verify implementation
httpserver.Verify = func(publicKey httpserver.PublicKey, message, sig []byte) bool {
Expand Down
6 changes: 3 additions & 3 deletions _examples/application_commands/localization/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -64,9 +65,8 @@ var (
)

func main() {
log.SetLevel(log.LevelTrace)
log.Info("starting example...")
log.Infof("disgo version: %s", disgo.Version)
slog.Info("starting example...")
slog.Info("disgo version", slog.String("version", disgo.Version))

client, err := disgo.New(token,
bot.WithDefaultGateway(),
Expand Down
2 changes: 1 addition & 1 deletion _examples/auto_moderation/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"time"

"github.com/disgoorg/json"
"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/components/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/events"

"github.com/disgoorg/log"
"log/slog"

"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/gateway"
Expand Down
2 changes: 1 addition & 1 deletion _examples/custom_cache/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"syscall"
"time"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/echo/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"syscall"
"time"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/guild_scheduled_events/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"syscall"
"time"

"github.com/disgoorg/log"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/handler/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os/signal"
"syscall"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/listening_events/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os/signal"
"syscall"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/message_collector/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"

"github.com/disgoorg/log"
"log/slog"

"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
Expand Down
2 changes: 1 addition & 1 deletion _examples/oauth2/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"time"

"github.com/disgoorg/json"
"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/discord"
Expand Down
2 changes: 1 addition & 1 deletion _examples/pagination/examplebot.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
_ "embed"
"os"

"github.com/disgoorg/log"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/rest"
Expand Down
2 changes: 1 addition & 1 deletion _examples/ping_pong/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os/signal"
"syscall"

"github.com/disgoorg/log"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/proxy/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os/signal"
"syscall"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/sharding/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os/signal"
"syscall"

"github.com/disgoorg/log"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/test/commands.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/disgoorg/log"
"log/slog"

"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/discord"
Expand Down
2 changes: 1 addition & 1 deletion _examples/test/examplebot.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"os/signal"
"syscall"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/test/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"time"

"github.com/disgoorg/log"
"log/slog"

"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/discord"
Expand Down
2 changes: 1 addition & 1 deletion _examples/threads/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os/signal"
"syscall"

"github.com/disgoorg/log"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/verified_roles/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"

"github.com/disgoorg/json"
"github.com/disgoorg/log"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/voice/voice.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/disgoorg/disgo/voice"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
Expand Down
2 changes: 1 addition & 1 deletion _examples/webhook/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"sync"
"time"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/discord"
Expand Down
11 changes: 5 additions & 6 deletions bot/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package bot

import (
"context"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"log/slog"

"github.com/disgoorg/disgo/cache"
"github.com/disgoorg/disgo/discord"
Expand All @@ -13,6 +11,7 @@ import (
"github.com/disgoorg/disgo/rest"
"github.com/disgoorg/disgo/sharding"
"github.com/disgoorg/disgo/voice"
"github.com/disgoorg/snowflake/v2"
)

var _ Client = (*clientImpl)(nil)
Expand All @@ -22,7 +21,7 @@ var _ Client = (*clientImpl)(nil)
// Create a new client with disgo.New.
type Client interface {
// Logger returns the logger for the client.
Logger() log.Logger
Logger() *slog.Logger

// Close will clean up all disgo internals and close the discord gracefully.
Close(ctx context.Context)
Expand Down Expand Up @@ -116,7 +115,7 @@ type clientImpl struct {
token string
applicationID snowflake.ID

logger log.Logger
logger *slog.Logger

restServices rest.Rest

Expand All @@ -134,7 +133,7 @@ type clientImpl struct {
memberChunkingManager MemberChunkingManager
}

func (c *clientImpl) Logger() log.Logger {
func (c *clientImpl) Logger() *slog.Logger {
return c.logger
}

Expand Down
Loading

0 comments on commit a06f865

Please sign in to comment.