From 44bac0adc5e6f060bfa7954141b586c3f540d8c0 Mon Sep 17 00:00:00 2001 From: Derek Duncan Date: Wed, 6 Sep 2023 09:21:04 -0500 Subject: [PATCH] Migrate from zerolog to slog (#248) * Begin adding new slog calls * Fixed unit tests * Add leveler example * Add debug log level to Redis example * Change location of server.Close() and add logs to example/hooks * Begin removing references to zerolog * Removed final references to zerolog * Change where server.Close() occurs in main * Change to 1.21 to remove x dependency * Add slog * Update references to 1.21 * Begin change of LogAttrs to standard logging interface * Change the rest of LogAttrs to default * Fix bad log * Update badger.go Changing "data" to "key" or "id" here might be more appropriate. * Update badger.go Changing "data" to "key" or "id" here might be more appropriate. * Update server.go Not checking if err is equal to nil * Update server.go printing information for ID or error is missing. * Change references of err.Error() to err in slog * Remove missed removal of Error() references for logging --------- Co-authored-by: Derek Duncan Co-authored-by: Derek Duncan Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com> Co-authored-by: werbenhu --- .github/workflows/build.yml | 4 +- Dockerfile | 2 +- clients.go | 3 +- clients_test.go | 2 +- cmd/main.go | 7 +- examples/auth/basic/main.go | 6 +- examples/auth/encoded/main.go | 6 +- examples/benchmark/main.go | 6 +- examples/debug/main.go | 16 +- examples/hooks/main.go | 36 +- examples/paho.testing/main.go | 6 +- examples/persistence/badger/main.go | 7 +- examples/persistence/bolt/main.go | 6 +- examples/persistence/redis/main.go | 17 +- examples/tcp/main.go | 6 +- examples/tls/main.go | 6 +- examples/websocket/main.go | 6 +- go.mod | 7 +- go.sum | 22 +- hooks.go | 52 +- hooks/auth/auth.go | 26 +- hooks/auth/auth_test.go | 22 +- hooks/debug/debug.go | 60 +- hooks/storage/badger/badger.go | 66 +- hooks/storage/badger/badger_test.go | 98 +- hooks/storage/bolt/bolt.go | 73 +- hooks/storage/bolt/bolt_test.go | 102 +- hooks/storage/redis/redis.go | 90 +- hooks/storage/redis/redis_test.go | 20 +- hooks_test.go | 26 +- listeners/http_healthcheck.go | 18 +- listeners/http_healthcheck_test.go | 10 +- listeners/http_sysinfo.go | 20 +- listeners/http_sysinfo_test.go | 8 +- listeners/listeners.go | 14 +- listeners/listeners_test.go | 5 +- listeners/mock.go | 4 +- listeners/net.go | 14 +- listeners/net_test.go | 6 +- listeners/tcp.go | 18 +- listeners/tcp_test.go | 12 +- listeners/unixsock.go | 16 +- listeners/unixsock_test.go | 8 +- listeners/websocket.go | 9 +- listeners/websocket_test.go | 8 +- server.go | 82 +- server_test.go | 84 +- vendor/github.com/mattn/go-colorable/LICENSE | 21 - .../github.com/mattn/go-colorable/README.md | 48 - .../mattn/go-colorable/colorable_appengine.go | 38 - .../mattn/go-colorable/colorable_others.go | 38 - .../mattn/go-colorable/colorable_windows.go | 1047 ----------------- .../github.com/mattn/go-colorable/go.test.sh | 12 - .../mattn/go-colorable/noncolorable.go | 57 - vendor/github.com/mattn/go-isatty/LICENSE | 9 - vendor/github.com/mattn/go-isatty/README.md | 50 - vendor/github.com/mattn/go-isatty/doc.go | 2 - vendor/github.com/mattn/go-isatty/go.test.sh | 12 - .../github.com/mattn/go-isatty/isatty_bsd.go | 19 - .../mattn/go-isatty/isatty_others.go | 16 - .../mattn/go-isatty/isatty_plan9.go | 23 - .../mattn/go-isatty/isatty_solaris.go | 21 - .../mattn/go-isatty/isatty_tcgets.go | 19 - .../mattn/go-isatty/isatty_windows.go | 125 -- vendor/github.com/rs/zerolog/.gitignore | 25 - vendor/github.com/rs/zerolog/CNAME | 1 - vendor/github.com/rs/zerolog/LICENSE | 21 - vendor/github.com/rs/zerolog/README.md | 716 ----------- vendor/github.com/rs/zerolog/_config.yml | 1 - vendor/github.com/rs/zerolog/array.go | 240 ---- vendor/github.com/rs/zerolog/console.go | 446 ------- vendor/github.com/rs/zerolog/context.go | 433 ------- vendor/github.com/rs/zerolog/ctx.go | 51 - vendor/github.com/rs/zerolog/encoder.go | 56 - vendor/github.com/rs/zerolog/encoder_cbor.go | 42 - vendor/github.com/rs/zerolog/encoder_json.go | 39 - vendor/github.com/rs/zerolog/event.go | 780 ------------ vendor/github.com/rs/zerolog/fields.go | 277 ----- vendor/github.com/rs/zerolog/globals.go | 142 --- vendor/github.com/rs/zerolog/go112.go | 7 - vendor/github.com/rs/zerolog/hook.go | 64 - .../rs/zerolog/internal/cbor/README.md | 56 - .../rs/zerolog/internal/cbor/base.go | 19 - .../rs/zerolog/internal/cbor/cbor.go | 101 -- .../rs/zerolog/internal/cbor/decode_stream.go | 614 ---------- .../rs/zerolog/internal/cbor/string.go | 95 -- .../rs/zerolog/internal/cbor/time.go | 93 -- .../rs/zerolog/internal/cbor/types.go | 477 -------- .../rs/zerolog/internal/json/base.go | 19 - .../rs/zerolog/internal/json/bytes.go | 85 -- .../rs/zerolog/internal/json/string.go | 149 --- .../rs/zerolog/internal/json/time.go | 113 -- .../rs/zerolog/internal/json/types.go | 405 ------- vendor/github.com/rs/zerolog/log.go | 476 -------- vendor/github.com/rs/zerolog/not_go112.go | 5 - vendor/github.com/rs/zerolog/pretty.png | Bin 84064 -> 0 bytes vendor/github.com/rs/zerolog/sampler.go | 134 --- vendor/github.com/rs/zerolog/syslog.go | 80 -- vendor/github.com/rs/zerolog/writer.go | 154 --- vendor/modules.txt | 15 +- 100 files changed, 561 insertions(+), 8569 deletions(-) delete mode 100644 vendor/github.com/mattn/go-colorable/LICENSE delete mode 100644 vendor/github.com/mattn/go-colorable/README.md delete mode 100644 vendor/github.com/mattn/go-colorable/colorable_appengine.go delete mode 100644 vendor/github.com/mattn/go-colorable/colorable_others.go delete mode 100644 vendor/github.com/mattn/go-colorable/colorable_windows.go delete mode 100644 vendor/github.com/mattn/go-colorable/go.test.sh delete mode 100644 vendor/github.com/mattn/go-colorable/noncolorable.go delete mode 100644 vendor/github.com/mattn/go-isatty/LICENSE delete mode 100644 vendor/github.com/mattn/go-isatty/README.md delete mode 100644 vendor/github.com/mattn/go-isatty/doc.go delete mode 100644 vendor/github.com/mattn/go-isatty/go.test.sh delete mode 100644 vendor/github.com/mattn/go-isatty/isatty_bsd.go delete mode 100644 vendor/github.com/mattn/go-isatty/isatty_others.go delete mode 100644 vendor/github.com/mattn/go-isatty/isatty_plan9.go delete mode 100644 vendor/github.com/mattn/go-isatty/isatty_solaris.go delete mode 100644 vendor/github.com/mattn/go-isatty/isatty_tcgets.go delete mode 100644 vendor/github.com/mattn/go-isatty/isatty_windows.go delete mode 100644 vendor/github.com/rs/zerolog/.gitignore delete mode 100644 vendor/github.com/rs/zerolog/CNAME delete mode 100644 vendor/github.com/rs/zerolog/LICENSE delete mode 100644 vendor/github.com/rs/zerolog/README.md delete mode 100644 vendor/github.com/rs/zerolog/_config.yml delete mode 100644 vendor/github.com/rs/zerolog/array.go delete mode 100644 vendor/github.com/rs/zerolog/console.go delete mode 100644 vendor/github.com/rs/zerolog/context.go delete mode 100644 vendor/github.com/rs/zerolog/ctx.go delete mode 100644 vendor/github.com/rs/zerolog/encoder.go delete mode 100644 vendor/github.com/rs/zerolog/encoder_cbor.go delete mode 100644 vendor/github.com/rs/zerolog/encoder_json.go delete mode 100644 vendor/github.com/rs/zerolog/event.go delete mode 100644 vendor/github.com/rs/zerolog/fields.go delete mode 100644 vendor/github.com/rs/zerolog/globals.go delete mode 100644 vendor/github.com/rs/zerolog/go112.go delete mode 100644 vendor/github.com/rs/zerolog/hook.go delete mode 100644 vendor/github.com/rs/zerolog/internal/cbor/README.md delete mode 100644 vendor/github.com/rs/zerolog/internal/cbor/base.go delete mode 100644 vendor/github.com/rs/zerolog/internal/cbor/cbor.go delete mode 100644 vendor/github.com/rs/zerolog/internal/cbor/decode_stream.go delete mode 100644 vendor/github.com/rs/zerolog/internal/cbor/string.go delete mode 100644 vendor/github.com/rs/zerolog/internal/cbor/time.go delete mode 100644 vendor/github.com/rs/zerolog/internal/cbor/types.go delete mode 100644 vendor/github.com/rs/zerolog/internal/json/base.go delete mode 100644 vendor/github.com/rs/zerolog/internal/json/bytes.go delete mode 100644 vendor/github.com/rs/zerolog/internal/json/string.go delete mode 100644 vendor/github.com/rs/zerolog/internal/json/time.go delete mode 100644 vendor/github.com/rs/zerolog/internal/json/types.go delete mode 100644 vendor/github.com/rs/zerolog/log.go delete mode 100644 vendor/github.com/rs/zerolog/not_go112.go delete mode 100644 vendor/github.com/rs/zerolog/pretty.png delete mode 100644 vendor/github.com/rs/zerolog/sampler.go delete mode 100644 vendor/github.com/rs/zerolog/syslog.go delete mode 100644 vendor/github.com/rs/zerolog/writer.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f8c6b863..7d166587 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 - name: Vet run: go vet ./... @@ -28,7 +28,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: '1.19' + go-version: '1.21' - name: Check out code uses: actions/checkout@v3 - name: Install dependencies diff --git a/Dockerfile b/Dockerfile index de71c8ba..dc3d2bd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19.0-alpine3.15 AS builder +FROM golang:1.21.0-alpine3.18 AS builder RUN apk update RUN apk add git diff --git a/clients.go b/clients.go index 75fe8685..33bb0100 100644 --- a/clients.go +++ b/clients.go @@ -192,7 +192,8 @@ func (cl *Client) WriteLoop() { select { case pk := <-cl.State.outbound: if err := cl.WritePacket(*pk); err != nil { - cl.ops.log.Debug().Err(err).Str("client", cl.ID).Interface("packet", pk).Msg("failed publishing packet") + // TODO : Figure out what to do with error + cl.ops.log.Debug("failed publishing packet", "error", err, "client", cl.ID, "packet", pk) } atomic.AddInt32(&cl.State.outboundQty, -1) case <-cl.State.open.Done(): diff --git a/clients_test.go b/clients_test.go index f7b6c48d..ae91de6d 100644 --- a/clients_test.go +++ b/clients_test.go @@ -29,7 +29,7 @@ func newTestClient() (cl *Client, r net.Conn, w net.Conn) { cl = newClient(w, &ops{ info: new(system.Info), hooks: new(Hooks), - log: &logger, + log: logger, options: &Options{ Capabilities: &Capabilities{ ReceiveMaximum: 10, diff --git a/cmd/main.go b/cmd/main.go index 701c911f..4ef3e827 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -11,7 +11,7 @@ import ( "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/listeners" ) @@ -59,7 +59,8 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") + } diff --git a/examples/auth/basic/main.go b/examples/auth/basic/main.go index 96d1ac92..0bc8b4d6 100644 --- a/examples/auth/basic/main.go +++ b/examples/auth/basic/main.go @@ -10,7 +10,7 @@ import ( "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/listeners" ) @@ -77,7 +77,7 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") } diff --git a/examples/auth/encoded/main.go b/examples/auth/encoded/main.go index a9e962e2..15477fb2 100644 --- a/examples/auth/encoded/main.go +++ b/examples/auth/encoded/main.go @@ -11,7 +11,7 @@ import ( "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/listeners" ) @@ -59,7 +59,7 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") } diff --git a/examples/benchmark/main.go b/examples/benchmark/main.go index 824446ba..f791b88d 100644 --- a/examples/benchmark/main.go +++ b/examples/benchmark/main.go @@ -11,7 +11,7 @@ import ( "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/listeners" ) @@ -46,7 +46,7 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") } diff --git a/examples/debug/main.go b/examples/debug/main.go index bd4a3b90..55cf0f0b 100644 --- a/examples/debug/main.go +++ b/examples/debug/main.go @@ -6,15 +6,15 @@ package main import ( "log" + "log/slog" "os" "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/hooks/debug" "github.com/mochi-mqtt/server/v2/listeners" - "github.com/rs/zerolog" ) func main() { @@ -27,8 +27,12 @@ func main() { }() server := mqtt.New(nil) - l := server.Log.Level(zerolog.DebugLevel) - server.Log = &l + + level := new(slog.LevelVar) + server.Log = slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ + Level: level, + })) + level.Set(slog.LevelDebug) err := server.AddHook(new(debug.Hook), &debug.Options{ // ShowPacketData: true, @@ -56,7 +60,7 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") } diff --git a/examples/hooks/main.go b/examples/hooks/main.go index d6357002..f24b414a 100644 --- a/examples/hooks/main.go +++ b/examples/hooks/main.go @@ -6,13 +6,14 @@ package main import ( "bytes" + "fmt" "log" "os" "os/signal" "syscall" "time" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/listeners" "github.com/mochi-mqtt/server/v2/packets" @@ -62,9 +63,9 @@ func main() { Payload: []byte("injected scheduled message"), }) if err != nil { - server.Log.Error().Err(err).Msg("server.InjectPacket") + server.Log.Error("server.InjectPacket", "error", err) } - server.Log.Info().Msgf("main.go injected packet to direct/publish") + server.Log.Info("main.go injected packet to direct/publish") } }() @@ -74,16 +75,16 @@ func main() { for range time.Tick(time.Second * 5) { err := server.Publish("direct/publish", []byte("packet scheduled message"), false, 0) if err != nil { - server.Log.Error().Err(err).Msg("server.Publish") + server.Log.Error("server.Publish", "error", err) } - server.Log.Info().Msgf("main.go issued direct message to direct/publish") + server.Log.Info("main.go issued direct message to direct/publish") } }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") } type ExampleHook struct { @@ -106,39 +107,44 @@ func (h *ExampleHook) Provides(b byte) bool { } func (h *ExampleHook) Init(config any) error { - h.Log.Info().Msg("initialised") + h.Log.Info("initialised") return nil } func (h *ExampleHook) OnConnect(cl *mqtt.Client, pk packets.Packet) error { - h.Log.Info().Str("client", cl.ID).Msgf("client connected") + h.Log.Info("client connected", "client", cl.ID) return nil } func (h *ExampleHook) OnDisconnect(cl *mqtt.Client, err error, expire bool) { - h.Log.Info().Str("client", cl.ID).Bool("expire", expire).Err(err).Msg("client disconnected") + if err != nil { + h.Log.Info("client disconnected", "client", cl.ID, "expire", expire, "error", err) + } else { + h.Log.Info("client disconnected", "client", cl.ID, "expire", expire) + } + } func (h *ExampleHook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []byte) { - h.Log.Info().Str("client", cl.ID).Interface("filters", pk.Filters).Msgf("subscribed qos=%v", reasonCodes) + h.Log.Info(fmt.Sprintf("subscribed qos=%v", reasonCodes), "client", cl.ID, "filters", pk.Filters) } func (h *ExampleHook) OnUnsubscribed(cl *mqtt.Client, pk packets.Packet) { - h.Log.Info().Str("client", cl.ID).Interface("filters", pk.Filters).Msg("unsubscribed") + h.Log.Info("unsubscribed", "client", cl.ID, "filters", pk.Filters) } func (h *ExampleHook) OnPublish(cl *mqtt.Client, pk packets.Packet) (packets.Packet, error) { - h.Log.Info().Str("client", cl.ID).Str("payload", string(pk.Payload)).Msg("received from client") + h.Log.Info("received from client", "client", cl.ID, "payload", string(pk.Payload)) pkx := pk if string(pk.Payload) == "hello" { pkx.Payload = []byte("hello world") - h.Log.Info().Str("client", cl.ID).Str("payload", string(pkx.Payload)).Msg("received modified packet from client") + h.Log.Info("received modified packet from client", "client", cl.ID, "payload", string(pkx.Payload)) } return pkx, nil } func (h *ExampleHook) OnPublished(cl *mqtt.Client, pk packets.Packet) { - h.Log.Info().Str("client", cl.ID).Str("payload", string(pk.Payload)).Msg("published to client") + h.Log.Info("published to client", "client", cl.ID, "payload", string(pk.Payload)) } diff --git a/examples/paho.testing/main.go b/examples/paho.testing/main.go index 97b5f0d5..cf92eacc 100644 --- a/examples/paho.testing/main.go +++ b/examples/paho.testing/main.go @@ -11,7 +11,7 @@ import ( "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/listeners" "github.com/mochi-mqtt/server/v2/packets" ) @@ -45,9 +45,9 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") } type pahoAuthHook struct { diff --git a/examples/persistence/badger/main.go b/examples/persistence/badger/main.go index 6a37ff6f..d0b88c75 100644 --- a/examples/persistence/badger/main.go +++ b/examples/persistence/badger/main.go @@ -10,7 +10,7 @@ import ( "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/hooks/storage/badger" "github.com/mochi-mqtt/server/v2/listeners" @@ -52,8 +52,7 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") - + server.Log.Info("main.go finished") } diff --git a/examples/persistence/bolt/main.go b/examples/persistence/bolt/main.go index b06b1ca0..7e05f30a 100644 --- a/examples/persistence/bolt/main.go +++ b/examples/persistence/bolt/main.go @@ -11,7 +11,7 @@ import ( "syscall" "time" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/hooks/storage/bolt" "github.com/mochi-mqtt/server/v2/listeners" @@ -54,7 +54,7 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") } diff --git a/examples/persistence/redis/main.go b/examples/persistence/redis/main.go index e9b173a0..9f300bb1 100644 --- a/examples/persistence/redis/main.go +++ b/examples/persistence/redis/main.go @@ -6,15 +6,15 @@ package main import ( "log" + "log/slog" "os" "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/hooks/storage/redis" "github.com/mochi-mqtt/server/v2/listeners" - "github.com/rs/zerolog" rv8 "github.com/go-redis/redis/v8" ) @@ -30,8 +30,12 @@ func main() { server := mqtt.New(nil) _ = server.AddHook(new(auth.AllowHook), nil) - l := server.Log.Level(zerolog.DebugLevel) - server.Log = &l + + level := new(slog.LevelVar) + server.Log = slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ + Level: level, + })) + level.Set(slog.LevelDebug) err := server.AddHook(new(redis.Hook), &redis.Options{ Options: &rv8.Options{ @@ -58,8 +62,7 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") - + server.Log.Info("main.go finished") } diff --git a/examples/tcp/main.go b/examples/tcp/main.go index 5e137674..2cb419d5 100644 --- a/examples/tcp/main.go +++ b/examples/tcp/main.go @@ -10,7 +10,7 @@ import ( "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/listeners" ) @@ -52,7 +52,7 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") } diff --git a/examples/tls/main.go b/examples/tls/main.go index cb51613f..fe9f93fb 100644 --- a/examples/tls/main.go +++ b/examples/tls/main.go @@ -11,7 +11,7 @@ import ( "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/listeners" ) @@ -111,7 +111,7 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") } diff --git a/examples/websocket/main.go b/examples/websocket/main.go index c1956280..7d427484 100644 --- a/examples/websocket/main.go +++ b/examples/websocket/main.go @@ -10,7 +10,7 @@ import ( "os/signal" "syscall" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/auth" "github.com/mochi-mqtt/server/v2/listeners" ) @@ -41,7 +41,7 @@ func main() { }() <-done - server.Log.Warn().Msg("caught signal, stopping...") + server.Log.Warn("caught signal, stopping...") server.Close() - server.Log.Info().Msg("main.go finished") + server.Log.Info("main.go finished") } diff --git a/go.mod b/go.mod index 442b32e9..376e7b18 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mochi-mqtt/server/v2 -go 1.19 +go 1.21 require ( github.com/alicebob/miniredis/v2 v2.23.0 @@ -10,7 +10,6 @@ require ( github.com/gorilla/websocket v1.5.0 github.com/jinzhu/copier v0.3.5 github.com/rs/xid v1.4.0 - github.com/rs/zerolog v1.28.0 github.com/stretchr/testify v1.7.1 github.com/timshannon/badgerhold v1.0.0 go.etcd.io/bbolt v1.3.5 @@ -28,13 +27,11 @@ require ( github.com/dustin/go-humanize v1.0.0 // indirect github.com/golang/protobuf v1.5.0 // indirect github.com/golang/snappy v0.0.3 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/google/go-cmp v0.5.8 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 // indirect golang.org/x/net v0.7.0 // indirect golang.org/x/sys v0.5.0 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/protobuf v1.28.1 // indirect ) diff --git a/go.sum b/go.sum index 820cf4ef..bbafb955 100644 --- a/go.sum +++ b/go.sum @@ -23,7 +23,6 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -38,9 +37,9 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4 github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4= @@ -48,8 +47,9 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= @@ -62,15 +62,14 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -79,8 +78,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= -github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= @@ -116,17 +113,14 @@ golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= @@ -136,8 +130,10 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/hooks.go b/hooks.go index 1af3c6df..25b625dc 100644 --- a/hooks.go +++ b/hooks.go @@ -1,20 +1,19 @@ // SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2022 mochi-mqtt, mochi-co -// SPDX-FileContributor: mochi-co, thedevop +// SPDX-FileContributor: mochi-co, thedevop, dgduncan package mqtt import ( "errors" "fmt" + "log/slog" "sync" "sync/atomic" "github.com/mochi-mqtt/server/v2/hooks/storage" "github.com/mochi-mqtt/server/v2/packets" "github.com/mochi-mqtt/server/v2/system" - - "github.com/rs/zerolog" ) const ( @@ -70,7 +69,7 @@ type Hook interface { Provides(b byte) bool Init(config any) error Stop() error - SetOpts(l *zerolog.Logger, o *HookOptions) + SetOpts(l *slog.Logger, o *HookOptions) OnStarted() OnStopped() OnConnectAuthenticate(cl *Client, pk packets.Packet) bool @@ -117,11 +116,11 @@ type HookOptions struct { // Hooks is a slice of Hook interfaces to be called in sequence. type Hooks struct { - Log *zerolog.Logger // a logger for the hook (from the server) - internal atomic.Value // a slice of []Hook - wg sync.WaitGroup // a waitgroup for syncing hook shutdown - qty int64 // the number of hooks in use - sync.Mutex // a mutex for locking when adding hooks + Log *slog.Logger // a logger for the hook (from the server) + internal atomic.Value // a slice of []Hook + wg sync.WaitGroup // a waitgroup for syncing hook shutdown + qty int64 // the number of hooks in use + sync.Mutex // a mutex for locking when adding hooks } // Len returns the number of hooks added. @@ -179,9 +178,9 @@ func (h *Hooks) GetAll() []Hook { func (h *Hooks) Stop() { go func() { for _, hook := range h.GetAll() { - h.Log.Info().Str("hook", hook.ID()).Msg("stopping hook") + h.Log.Info("stopping hook", "hook", hook.ID()) if err := hook.Stop(); err != nil { - h.Log.Debug().Err(err).Str("hook", hook.ID()).Msg("problem stopping hook") + h.Log.Debug("problem stopping hook", "error", err, "hook", hook.ID()) } h.wg.Done() @@ -266,7 +265,7 @@ func (h *Hooks) OnPacketRead(cl *Client, pk packets.Packet) (pkx packets.Packet, if hook.Provides(OnPacketRead) { npk, err := hook.OnPacketRead(cl, pkx) if err != nil && errors.Is(err, packets.ErrRejectPacket) { - h.Log.Debug().Err(err).Str("hook", hook.ID()).Interface("packet", pkx).Msg("packet rejected") + h.Log.Debug("packet rejected", "hook", hook.ID(), "packet", pkx) return pk, err } else if err != nil { continue @@ -394,10 +393,16 @@ func (h *Hooks) OnPublish(cl *Client, pk packets.Packet) (pkx packets.Packet, er npk, err := hook.OnPublish(cl, pkx) if err != nil { if errors.Is(err, packets.ErrRejectPacket) { - h.Log.Debug().Err(err).Str("hook", hook.ID()).Interface("packet", pkx).Msg("publish packet rejected") + h.Log.Debug("publish packet rejected", + "error", err, + "hook", hook.ID(), + "packet", pkx) return pk, err } - h.Log.Error().Err(err).Str("hook", hook.ID()).Interface("packet", pkx).Msg("publish packet error") + h.Log.Error("publish packet error", + "error", err, + "hook", hook.ID(), + "packet", pkx) return pk, err } pkx = npk @@ -496,7 +501,10 @@ func (h *Hooks) OnWill(cl *Client, will Will) Will { if hook.Provides(OnWill) { mlwt, err := hook.OnWill(cl, will) if err != nil { - h.Log.Error().Err(err).Str("hook", hook.ID()).Interface("will", will).Msg("parse will error") + h.Log.Error("parse will error", + "error", err, + "hook", hook.ID(), + "will", will) continue } will = mlwt @@ -540,7 +548,7 @@ func (h *Hooks) StoredClients() (v []storage.Client, err error) { if hook.Provides(StoredClients) { v, err := hook.StoredClients() if err != nil { - h.Log.Error().Err(err).Str("hook", hook.ID()).Msg("failed to load clients") + h.Log.Error("failed to load clients", "error", err, "hook", hook.ID()) return v, err } @@ -560,7 +568,7 @@ func (h *Hooks) StoredSubscriptions() (v []storage.Subscription, err error) { if hook.Provides(StoredSubscriptions) { v, err := hook.StoredSubscriptions() if err != nil { - h.Log.Error().Err(err).Str("hook", hook.ID()).Msg("failed to load subscriptions") + h.Log.Error("failed to load subscriptions", "error", err, "hook", hook.ID()) return v, err } @@ -580,7 +588,7 @@ func (h *Hooks) StoredInflightMessages() (v []storage.Message, err error) { if hook.Provides(StoredInflightMessages) { v, err := hook.StoredInflightMessages() if err != nil { - h.Log.Error().Err(err).Str("hook", hook.ID()).Msg("failed to load inflight messages") + h.Log.Error("failed to load inflight messages", "error", err, "hook", hook.ID()) return v, err } @@ -600,7 +608,7 @@ func (h *Hooks) StoredRetainedMessages() (v []storage.Message, err error) { if hook.Provides(StoredRetainedMessages) { v, err := hook.StoredRetainedMessages() if err != nil { - h.Log.Error().Err(err).Str("hook", hook.ID()).Msg("failed to load retained messages") + h.Log.Error("failed to load retained messages", "error", err, "hook", hook.ID()) return v, err } @@ -619,7 +627,7 @@ func (h *Hooks) StoredSysInfo() (v storage.SystemInfo, err error) { if hook.Provides(StoredSysInfo) { v, err := hook.StoredSysInfo() if err != nil { - h.Log.Error().Err(err).Str("hook", hook.ID()).Msg("failed to load $SYS info") + h.Log.Error("failed to load $SYS info", "error", err, "hook", hook.ID()) return v, err } @@ -668,7 +676,7 @@ func (h *Hooks) OnACLCheck(cl *Client, topic string, write bool) bool { // all hooks. type HookBase struct { Hook - Log *zerolog.Logger + Log *slog.Logger Opts *HookOptions } @@ -691,7 +699,7 @@ func (h *HookBase) Init(config any) error { // SetOpts is called by the server to propagate internal values and generally should // not be called manually. -func (h *HookBase) SetOpts(l *zerolog.Logger, opts *HookOptions) { +func (h *HookBase) SetOpts(l *slog.Logger, opts *HookOptions) { h.Log = l h.Opts = opts } diff --git a/hooks/auth/auth.go b/hooks/auth/auth.go index ed914613..d50cc5ce 100644 --- a/hooks/auth/auth.go +++ b/hooks/auth/auth.go @@ -7,7 +7,7 @@ package auth import ( "bytes" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/packets" ) @@ -67,10 +67,9 @@ func (h *Hook) Init(config any) error { } } - h.Log.Info(). - Int("authentication", len(h.ledger.Auth)). - Int("acl", len(h.ledger.ACL)). - Msg("loaded auth rules") + h.Log.Info("loaded auth rules", + "authentication", len(h.ledger.Auth), + "acl", len(h.ledger.ACL)) return nil } @@ -82,11 +81,9 @@ func (h *Hook) OnConnectAuthenticate(cl *mqtt.Client, pk packets.Packet) bool { return true } - h.Log.Info(). - Str("username", string(pk.Connect.Username)). - Str("remote", cl.Net.Remote). - Msg("client failed authentication check") - + h.Log.Info("client failed authentication check", + "username", string(pk.Connect.Username), + "remote", cl.Net.Remote) return false } @@ -97,11 +94,10 @@ func (h *Hook) OnACLCheck(cl *mqtt.Client, topic string, write bool) bool { return true } - h.Log.Debug(). - Str("client", cl.ID). - Str("username", string(cl.Properties.Username)). - Str("topic", topic). - Msg("client failed allowed ACL check") + h.Log.Debug("client failed allowed ACL check", + "client", cl.ID, + "username", string(cl.Properties.Username), + "topic", topic) return false } diff --git a/hooks/auth/auth_test.go b/hooks/auth/auth_test.go index 604d8e91..86901f33 100644 --- a/hooks/auth/auth_test.go +++ b/hooks/auth/auth_test.go @@ -5,16 +5,16 @@ package auth import ( + "log/slog" "os" "testing" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/packets" - "github.com/rs/zerolog" "github.com/stretchr/testify/require" ) -var logger = zerolog.New(os.Stderr).With().Timestamp().Logger().Level(zerolog.Disabled) +var logger = slog.New(slog.NewTextHandler(os.Stdout, nil)) // func teardown(t *testing.T, path string, h *Hook) { // h.Stop() @@ -34,7 +34,7 @@ func TestBasicProvides(t *testing.T) { func TestBasicInitBadConfig(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(map[string]any{}) require.Error(t, err) @@ -42,7 +42,7 @@ func TestBasicInitBadConfig(t *testing.T) { func TestBasicInitDefaultConfig(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) @@ -50,7 +50,7 @@ func TestBasicInitDefaultConfig(t *testing.T) { func TestBasicInitWithLedgerPointer(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) ln := &Ledger{ Auth: []AuthRule{ @@ -79,7 +79,7 @@ func TestBasicInitWithLedgerPointer(t *testing.T) { func TestBasicInitWithLedgerJSON(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) require.Nil(t, h.ledger) err := h.Init(&Options{ @@ -93,7 +93,7 @@ func TestBasicInitWithLedgerJSON(t *testing.T) { func TestBasicInitWithLedgerYAML(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) require.Nil(t, h.ledger) err := h.Init(&Options{ @@ -107,7 +107,7 @@ func TestBasicInitWithLedgerYAML(t *testing.T) { func TestBasicInitWithLedgerBadDAta(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) require.Nil(t, h.ledger) err := h.Init(&Options{ @@ -119,7 +119,7 @@ func TestBasicInitWithLedgerBadDAta(t *testing.T) { func TestOnConnectAuthenticate(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) ln := new(Ledger) ln.Auth = checkLedger.Auth @@ -158,7 +158,7 @@ func TestOnConnectAuthenticate(t *testing.T) { func TestOnACL(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) ln := new(Ledger) ln.Auth = checkLedger.Auth diff --git a/hooks/debug/debug.go b/hooks/debug/debug.go index 08ec7691..00404f20 100644 --- a/hooks/debug/debug.go +++ b/hooks/debug/debug.go @@ -5,13 +5,13 @@ package debug import ( + "fmt" + "log/slog" "strings" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/storage" "github.com/mochi-mqtt/server/v2/packets" - - "github.com/rs/zerolog" ) // Options contains configuration settings for the debug output. @@ -25,7 +25,7 @@ type Options struct { type Hook struct { mqtt.HookBase config *Options - Log *zerolog.Logger + Log *slog.Logger } // ID returns the ID of the hook. @@ -54,25 +54,25 @@ func (h *Hook) Init(config any) error { } // SetOpts is called when the hook receives inheritable server parameters. -func (h *Hook) SetOpts(l *zerolog.Logger, opts *mqtt.HookOptions) { +func (h *Hook) SetOpts(l *slog.Logger, opts *mqtt.HookOptions) { h.Log = l - h.Log.Debug().Interface("opts", opts).Str("method", "SetOpts").Send() + h.Log.Debug("", "method", "SetOpts") } // Stop is called when the hook is stopped. func (h *Hook) Stop() error { - h.Log.Debug().Str("method", "Stop").Send() + h.Log.Debug("", "method", "Stop") return nil } // OnStarted is called when the server starts. func (h *Hook) OnStarted() { - h.Log.Debug().Str("method", "OnStarted").Send() + h.Log.Debug("", "method", "OnStarted") } // OnStopped is called when the server stops. func (h *Hook) OnStopped() { - h.Log.Debug().Str("method", "OnStopped").Send() + h.Log.Debug("", "method", "OnStopped") } // OnPacketRead is called when a new packet is received from a client. @@ -81,8 +81,7 @@ func (h *Hook) OnPacketRead(cl *mqtt.Client, pk packets.Packet) (packets.Packet, return pk, nil } - h.Log.Debug().Interface("m", h.packetMeta(pk)).Msgf("%s << %s", strings.ToUpper(packets.PacketNames[pk.FixedHeader.Type]), cl.ID) - + h.Log.Debug(fmt.Sprintf("%s << %s", strings.ToUpper(packets.PacketNames[pk.FixedHeader.Type]), cl.ID), "m", h.packetMeta(pk)) return pk, nil } @@ -92,85 +91,72 @@ func (h *Hook) OnPacketSent(cl *mqtt.Client, pk packets.Packet, b []byte) { return } - h.Log.Debug().Interface("m", h.packetMeta(pk)).Msgf("%s >> %s", strings.ToUpper(packets.PacketNames[pk.FixedHeader.Type]), cl.ID) + h.Log.Debug(fmt.Sprintf("%s >> %s", strings.ToUpper(packets.PacketNames[pk.FixedHeader.Type]), cl.ID), "m", h.packetMeta(pk)) } // OnRetainMessage is called when a published message is retained (or retain deleted/modified). func (h *Hook) OnRetainMessage(cl *mqtt.Client, pk packets.Packet, r int64) { - h.Log.Debug().Interface("m", h.packetMeta(pk)).Msgf("retained message on topic") + h.Log.Debug("retained message on topic", "m", h.packetMeta(pk)) } // OnQosPublish is called when a publish packet with Qos is issued to a subscriber. func (h *Hook) OnQosPublish(cl *mqtt.Client, pk packets.Packet, sent int64, resends int) { - h.Log.Debug().Interface("m", h.packetMeta(pk)).Msgf("inflight out") + h.Log.Debug("inflight out", "m", h.packetMeta(pk)) } // OnQosComplete is called when the Qos flow for a message has been completed. func (h *Hook) OnQosComplete(cl *mqtt.Client, pk packets.Packet) { - h.Log.Debug().Interface("m", h.packetMeta(pk)).Msgf("inflight complete") + h.Log.Debug("inflight complete", "m", h.packetMeta(pk)) } // OnQosDropped is called the Qos flow for a message expires. func (h *Hook) OnQosDropped(cl *mqtt.Client, pk packets.Packet) { - h.Log.Debug().Interface("m", h.packetMeta(pk)).Msgf("inflight dropped") + h.Log.Debug("inflight dropped", "m", h.packetMeta(pk)) } // OnLWTSent is called when a will message has been issued from a disconnecting client. func (h *Hook) OnLWTSent(cl *mqtt.Client, pk packets.Packet) { - h.Log.Debug().Str("method", "OnLWTSent").Str("client", cl.ID).Msg("sent lwt for client") + h.Log.Debug("sent lwt for client", "method", "OnLWTSent", "client", cl.ID) } // OnRetainedExpired is called when the server clears expired retained messages. func (h *Hook) OnRetainedExpired(filter string) { - h.Log.Debug().Str("method", "OnRetainedExpired").Str("topic", filter).Msg("retained message expired") + h.Log.Debug("retained message expired", "method", "OnRetainedExpired", "topic", filter) } // OnClientExpired is called when the server clears an expired client. func (h *Hook) OnClientExpired(cl *mqtt.Client) { - h.Log.Debug().Str("method", "OnClientExpired").Str("client", cl.ID).Msg("client session expired") + h.Log.Debug("client session expired", "method", "OnClientExpired", "client", cl.ID) } // StoredClients is called when the server restores clients from a store. func (h *Hook) StoredClients() (v []storage.Client, err error) { - h.Log.Debug(). - Str("method", "StoredClients"). - Send() + h.Log.Debug("", "method", "StoredClients") return v, nil } // StoredClients is called when the server restores subscriptions from a store. func (h *Hook) StoredSubscriptions() (v []storage.Subscription, err error) { - h.Log.Debug(). - Str("method", "StoredSubscriptions"). - Send() - + h.Log.Debug("", "method", "StoredSubscriptions") return v, nil } // StoredClients is called when the server restores retained messages from a store. func (h *Hook) StoredRetainedMessages() (v []storage.Message, err error) { - h.Log.Debug(). - Str("method", "StoredRetainedMessages"). - Send() - + h.Log.Debug("", "method", "StoredRetainedMessages") return v, nil } // StoredClients is called when the server restores inflight messages from a store. func (h *Hook) StoredInflightMessages() (v []storage.Message, err error) { - h.Log.Debug(). - Str("method", "StoredInflightMessages"). - Send() - + h.Log.Debug("", "method", "StoredInflightMessages") return v, nil } // StoredClients is called when the server restores system info from a store. func (h *Hook) StoredSysInfo() (v storage.SystemInfo, err error) { - h.Log.Debug(). - Str("method", "StoredClients"). - Send() + h.Log.Debug("", "method", "StoredSysInfo") return v, nil } diff --git a/hooks/storage/badger/badger.go b/hooks/storage/badger/badger.go index b8712c1b..ca416f66 100644 --- a/hooks/storage/badger/badger.go +++ b/hooks/storage/badger/badger.go @@ -7,9 +7,10 @@ package badger import ( "bytes" "errors" + "fmt" "strings" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/storage" "github.com/mochi-mqtt/server/v2/packets" "github.com/mochi-mqtt/server/v2/system" @@ -136,7 +137,7 @@ func (h *Hook) OnWillSent(cl *mqtt.Client, pk packets.Packet) { // updateClient writes the client data to the store. func (h *Hook) updateClient(cl *mqtt.Client) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -165,14 +166,14 @@ func (h *Hook) updateClient(cl *mqtt.Client) { err := h.db.Upsert(in.ID, in) if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to upsert client data") + h.Log.Error("failed to upsert client data", "error", err, "data", in) } } // OnDisconnect removes a client from the store if their session has expired. func (h *Hook) OnDisconnect(cl *mqtt.Client, _ error, expire bool) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -188,14 +189,14 @@ func (h *Hook) OnDisconnect(cl *mqtt.Client, _ error, expire bool) { err := h.db.Delete(clientKey(cl), new(storage.Client)) if err != nil { - h.Log.Error().Err(err).Interface("data", clientKey(cl)).Msg("failed to delete client data") + h.Log.Error("failed to delete client data", "error", err, "data", clientKey(cl)) } } // OnSubscribed adds one or more client subscriptions to the store. func (h *Hook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []byte) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -215,7 +216,7 @@ func (h *Hook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []by err := h.db.Upsert(in.ID, in) if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to upsert subscription data") + h.Log.Error("failed to upsert subscription data", "error", err, "data", in) } } } @@ -223,14 +224,14 @@ func (h *Hook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []by // OnUnsubscribed removes one or more client subscriptions from the store. func (h *Hook) OnUnsubscribed(cl *mqtt.Client, pk packets.Packet) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } for i := 0; i < len(pk.Filters); i++ { err := h.db.Delete(subscriptionKey(cl, pk.Filters[i].Filter), new(storage.Subscription)) if err != nil { - h.Log.Error().Err(err).Interface("data", subscriptionKey(cl, pk.Filters[i].Filter)).Msg("failed to delete subscription data") + h.Log.Error("failed to delete subscription data", "error", err, "data", subscriptionKey(cl, pk.Filters[i].Filter)) } } } @@ -238,14 +239,14 @@ func (h *Hook) OnUnsubscribed(cl *mqtt.Client, pk packets.Packet) { // OnRetainMessage adds a retained message for a topic to the store. func (h *Hook) OnRetainMessage(cl *mqtt.Client, pk packets.Packet, r int64) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } if r == -1 { err := h.db.Delete(retainedKey(pk.TopicName), new(storage.Message)) if err != nil { - h.Log.Error().Err(err).Interface("data", retainedKey(pk.TopicName)).Msg("failed to delete retained message data") + h.Log.Error("failed to delete retained message data", "error", err, "data", retainedKey(pk.TopicName)) } return @@ -274,14 +275,14 @@ func (h *Hook) OnRetainMessage(cl *mqtt.Client, pk packets.Packet, r int64) { err := h.db.Upsert(in.ID, in) if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to upsert retained message data") + h.Log.Error("failed to upsert retained message data", "error", err, "data", in) } } // OnQosPublish adds or updates an inflight message in the store. func (h *Hook) OnQosPublish(cl *mqtt.Client, pk packets.Packet, sent int64, resends int) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -310,27 +311,27 @@ func (h *Hook) OnQosPublish(cl *mqtt.Client, pk packets.Packet, sent int64, rese err := h.db.Upsert(in.ID, in) if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to upsert qos inflight data") + h.Log.Error("failed to upsert qos inflight data", "error", err, "data", in) } } // OnQosComplete removes a resolved inflight message from the store. func (h *Hook) OnQosComplete(cl *mqtt.Client, pk packets.Packet) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } err := h.db.Delete(inflightKey(cl, pk), new(storage.Message)) if err != nil { - h.Log.Error().Err(err).Interface("data", inflightKey(cl, pk)).Msg("failed to delete inflight message data") + h.Log.Error("failed to delete inflight message data", "error", err, "data", inflightKey(cl, pk)) } } // OnQosDropped removes a dropped inflight message from the store. func (h *Hook) OnQosDropped(cl *mqtt.Client, pk packets.Packet) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) } h.OnQosComplete(cl, pk) @@ -339,7 +340,7 @@ func (h *Hook) OnQosDropped(cl *mqtt.Client, pk packets.Packet) { // OnSysInfoTick stores the latest system info in the store. func (h *Hook) OnSysInfoTick(sys *system.Info) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -351,40 +352,40 @@ func (h *Hook) OnSysInfoTick(sys *system.Info) { err := h.db.Upsert(in.ID, in) if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to upsert $SYS data") + h.Log.Error("failed to upsert $SYS data", "error", err, "data", in) } } // OnRetainedExpired deletes expired retained messages from the store. func (h *Hook) OnRetainedExpired(filter string) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } err := h.db.Delete(retainedKey(filter), new(storage.Message)) if err != nil { - h.Log.Error().Err(err).Str("id", retainedKey(filter)).Msg("failed to delete expired retained message data") + h.Log.Error("failed to delete expired retained message data", "error", err, "id", retainedKey(filter)) } } // OnClientExpired deleted expired clients from the store. func (h *Hook) OnClientExpired(cl *mqtt.Client) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } err := h.db.Delete(clientKey(cl), new(storage.Client)) if err != nil { - h.Log.Error().Err(err).Str("id", clientKey(cl)).Msg("failed to delete expired client data") + h.Log.Error("failed to delete expired client data", "error", err, "id", clientKey(cl)) } } // StoredClients returns all stored clients from the store. func (h *Hook) StoredClients() (v []storage.Client, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -399,7 +400,7 @@ func (h *Hook) StoredClients() (v []storage.Client, err error) { // StoredSubscriptions returns all stored subscriptions from the store. func (h *Hook) StoredSubscriptions() (v []storage.Subscription, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -414,7 +415,7 @@ func (h *Hook) StoredSubscriptions() (v []storage.Subscription, err error) { // StoredRetainedMessages returns all stored retained messages from the store. func (h *Hook) StoredRetainedMessages() (v []storage.Message, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -429,7 +430,7 @@ func (h *Hook) StoredRetainedMessages() (v []storage.Message, err error) { // StoredInflightMessages returns all stored inflight messages from the store. func (h *Hook) StoredInflightMessages() (v []storage.Message, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -444,7 +445,7 @@ func (h *Hook) StoredInflightMessages() (v []storage.Message, err error) { // StoredSysInfo returns the system info from the store. func (h *Hook) StoredSysInfo() (v storage.SystemInfo, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -458,20 +459,21 @@ func (h *Hook) StoredSysInfo() (v storage.SystemInfo, err error) { // Errorf satisfies the badger interface for an error logger. func (h *Hook) Errorf(m string, v ...interface{}) { - h.Log.Error().Interface("v", v).Msgf(strings.ToLower(strings.Trim(m, "\n")), v...) + h.Log.Error(fmt.Sprintf(strings.ToLower(strings.Trim(m, "\n")), v...), "v", v) + } // Warningf satisfies the badger interface for a warning logger. func (h *Hook) Warningf(m string, v ...interface{}) { - h.Log.Warn().Interface("v", v).Msgf(strings.ToLower(strings.Trim(m, "\n")), v...) + h.Log.Warn(fmt.Sprintf(strings.ToLower(strings.Trim(m, "\n")), v...), "v", v) } // Infof satisfies the badger interface for an info logger. func (h *Hook) Infof(m string, v ...interface{}) { - h.Log.Info().Interface("v", v).Msgf(strings.ToLower(strings.Trim(m, "\n")), v...) + h.Log.Info(fmt.Sprintf(strings.ToLower(strings.Trim(m, "\n")), v...), "v", v) } // Debugf satisfies the badger interface for a debug logger. func (h *Hook) Debugf(m string, v ...interface{}) { - h.Log.Debug().Interface("v", v).Msgf(strings.ToLower(strings.Trim(m, "\n")), v...) + h.Log.Debug(fmt.Sprintf(strings.ToLower(strings.Trim(m, "\n")), v...), "v", v) } diff --git a/hooks/storage/badger/badger_test.go b/hooks/storage/badger/badger_test.go index ba418bf7..08003670 100644 --- a/hooks/storage/badger/badger_test.go +++ b/hooks/storage/badger/badger_test.go @@ -5,22 +5,22 @@ package badger import ( + "log/slog" "os" "strings" "testing" "time" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/storage" "github.com/mochi-mqtt/server/v2/packets" "github.com/mochi-mqtt/server/v2/system" - "github.com/rs/zerolog" "github.com/stretchr/testify/require" "github.com/timshannon/badgerhold" ) var ( - logger = zerolog.New(os.Stderr).With().Timestamp().Logger().Level(zerolog.Disabled) + logger = slog.New(slog.NewTextHandler(os.Stdout, nil)) client = &mqtt.Client{ ID: "test", @@ -95,7 +95,7 @@ func TestProvides(t *testing.T) { func TestInitBadConfig(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(map[string]any{}) require.Error(t, err) @@ -103,7 +103,7 @@ func TestInitBadConfig(t *testing.T) { func TestInitUseDefaults(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -113,7 +113,7 @@ func TestInitUseDefaults(t *testing.T) { func TestOnSessionEstablishedThenOnDisconnect(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -146,7 +146,7 @@ func TestOnSessionEstablishedThenOnDisconnect(t *testing.T) { func TestOnClientExpired(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -170,13 +170,13 @@ func TestOnClientExpired(t *testing.T) { func TestOnClientExpiredNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnClientExpired(client) } func TestOnClientExpiredClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -185,13 +185,13 @@ func TestOnClientExpiredClosedDB(t *testing.T) { func TestOnSessionEstablishedNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnSessionEstablished(client, packets.Packet{}) } func TestOnSessionEstablishedClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -200,7 +200,7 @@ func TestOnSessionEstablishedClosedDB(t *testing.T) { func TestOnWillSent(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -219,13 +219,13 @@ func TestOnWillSent(t *testing.T) { func TestOnDisconnectNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnDisconnect(client, nil, false) } func TestOnDisconnectClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -234,7 +234,7 @@ func TestOnDisconnectClosedDB(t *testing.T) { func TestOnDisconnectSessionTakenOver(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) @@ -257,7 +257,7 @@ func TestOnDisconnectSessionTakenOver(t *testing.T) { func TestOnSubscribedThenOnUnsubscribed(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -279,13 +279,13 @@ func TestOnSubscribedThenOnUnsubscribed(t *testing.T) { func TestOnSubscribedNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnSubscribed(client, pkf, []byte{0}) } func TestOnSubscribedClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -294,13 +294,13 @@ func TestOnSubscribedClosedDB(t *testing.T) { func TestOnUnsubscribedNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnUnsubscribed(client, pkf) } func TestOnUnsubscribedClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -309,7 +309,7 @@ func TestOnUnsubscribedClosedDB(t *testing.T) { func TestOnRetainMessageThenUnset(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -344,7 +344,7 @@ func TestOnRetainMessageThenUnset(t *testing.T) { func TestOnRetainedExpired(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -371,13 +371,13 @@ func TestOnRetainedExpired(t *testing.T) { func TestOnRetainExpiredNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnRetainedExpired("a/b/c") } func TestOnRetainExpiredClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -386,13 +386,13 @@ func TestOnRetainExpiredClosedDB(t *testing.T) { func TestOnRetainMessageNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnRetainMessage(client, packets.Packet{}, 0) } func TestOnRetainMessageClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -401,7 +401,7 @@ func TestOnRetainMessageClosedDB(t *testing.T) { func TestOnQosPublishThenQOSComplete(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -436,13 +436,13 @@ func TestOnQosPublishThenQOSComplete(t *testing.T) { func TestOnQosPublishNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnQosPublish(client, packets.Packet{}, time.Now().Unix(), 0) } func TestOnQosPublishClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -451,13 +451,13 @@ func TestOnQosPublishClosedDB(t *testing.T) { func TestOnQosCompleteNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnQosComplete(client, packets.Packet{}) } func TestOnQosCompleteClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -466,13 +466,13 @@ func TestOnQosCompleteClosedDB(t *testing.T) { func TestOnQosDroppedNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnQosDropped(client, packets.Packet{}) } func TestOnSysInfoTick(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -494,13 +494,13 @@ func TestOnSysInfoTick(t *testing.T) { func TestOnSysInfoTickNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnSysInfoTick(new(system.Info)) } func TestOnSysInfoTickClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -509,7 +509,7 @@ func TestOnSysInfoTickClosedDB(t *testing.T) { func TestStoredClients(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -534,7 +534,7 @@ func TestStoredClients(t *testing.T) { func TestStoredClientsNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) v, err := h.StoredClients() require.Empty(t, v) require.NoError(t, err) @@ -542,7 +542,7 @@ func TestStoredClientsNoDB(t *testing.T) { func TestStoredSubscriptions(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -567,7 +567,7 @@ func TestStoredSubscriptions(t *testing.T) { func TestStoredSubscriptionsNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) v, err := h.StoredSubscriptions() require.Empty(t, v) require.NoError(t, err) @@ -575,7 +575,7 @@ func TestStoredSubscriptionsNoDB(t *testing.T) { func TestStoredRetainedMessages(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -603,7 +603,7 @@ func TestStoredRetainedMessages(t *testing.T) { func TestStoredRetainedMessagesNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) v, err := h.StoredRetainedMessages() require.Empty(t, v) require.NoError(t, err) @@ -611,7 +611,7 @@ func TestStoredRetainedMessagesNoDB(t *testing.T) { func TestStoredInflightMessages(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -639,7 +639,7 @@ func TestStoredInflightMessages(t *testing.T) { func TestStoredInflightMessagesNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) v, err := h.StoredInflightMessages() require.Empty(t, v) require.NoError(t, err) @@ -647,7 +647,7 @@ func TestStoredInflightMessagesNoDB(t *testing.T) { func TestStoredSysInfo(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -669,7 +669,7 @@ func TestStoredSysInfo(t *testing.T) { func TestStoredSysInfoNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) v, err := h.StoredSysInfo() require.Empty(t, v) require.NoError(t, err) @@ -678,27 +678,27 @@ func TestStoredSysInfoNoDB(t *testing.T) { func TestErrorf(t *testing.T) { // coverage: one day check log hook h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.Errorf("test", 1, 2, 3) } func TestWarningf(t *testing.T) { // coverage: one day check log hook h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.Warningf("test", 1, 2, 3) } func TestInfof(t *testing.T) { // coverage: one day check log hook h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.Infof("test", 1, 2, 3) } func TestDebugf(t *testing.T) { // coverage: one day check log hook h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.Debugf("test", 1, 2, 3) } diff --git a/hooks/storage/bolt/bolt.go b/hooks/storage/bolt/bolt.go index b4a2f894..b57c24ac 100644 --- a/hooks/storage/bolt/bolt.go +++ b/hooks/storage/bolt/bolt.go @@ -9,7 +9,7 @@ import ( "errors" "time" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/storage" "github.com/mochi-mqtt/server/v2/packets" "github.com/mochi-mqtt/server/v2/system" @@ -141,7 +141,7 @@ func (h *Hook) OnWillSent(cl *mqtt.Client, pk packets.Packet) { // updateClient writes the client data to the store. func (h *Hook) updateClient(cl *mqtt.Client) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -169,14 +169,14 @@ func (h *Hook) updateClient(cl *mqtt.Client) { } err := h.db.Save(in) if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to save client data") + h.Log.Error("failed to save client data", "error", err, "data", in) } } // OnDisconnect removes a client from the store if they were using a clean session. func (h *Hook) OnDisconnect(cl *mqtt.Client, _ error, expire bool) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -190,14 +190,14 @@ func (h *Hook) OnDisconnect(cl *mqtt.Client, _ error, expire bool) { err := h.db.DeleteStruct(&storage.Client{ID: clientKey(cl)}) if err != nil && !errors.Is(err, storm.ErrNotFound) { - h.Log.Error().Err(err).Str("id", clientKey(cl)).Msg("failed to delete client") + h.Log.Error("failed to delete client", "error", err, "id", clientKey(cl)) } } // OnSubscribed adds one or more client subscriptions to the store. func (h *Hook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []byte) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -217,10 +217,7 @@ func (h *Hook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []by err := h.db.Save(in) if err != nil { - h.Log.Error().Err(err). - Str("client", cl.ID). - Interface("data", in). - Msg("failed to save subscription data") + h.Log.Error("failed to save subscription data", "error", err, "client", cl.ID, "data", in) } } } @@ -228,7 +225,7 @@ func (h *Hook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []by // OnUnsubscribed removes one or more client subscriptions from the store. func (h *Hook) OnUnsubscribed(cl *mqtt.Client, pk packets.Packet) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -237,9 +234,7 @@ func (h *Hook) OnUnsubscribed(cl *mqtt.Client, pk packets.Packet) { ID: subscriptionKey(cl, pk.Filters[i].Filter), }) if err != nil { - h.Log.Error().Err(err). - Str("id", subscriptionKey(cl, pk.Filters[i].Filter)). - Msg("failed to delete client") + h.Log.Error("failed to delete client", "error", err, "id", subscriptionKey(cl, pk.Filters[i].Filter)) } } } @@ -247,7 +242,7 @@ func (h *Hook) OnUnsubscribed(cl *mqtt.Client, pk packets.Packet) { // OnRetainMessage adds a retained message for a topic to the store. func (h *Hook) OnRetainMessage(cl *mqtt.Client, pk packets.Packet, r int64) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -256,9 +251,7 @@ func (h *Hook) OnRetainMessage(cl *mqtt.Client, pk packets.Packet, r int64) { ID: retainedKey(pk.TopicName), }) if err != nil { - h.Log.Error().Err(err). - Str("id", retainedKey(pk.TopicName)). - Msg("failed to delete retained publish") + h.Log.Error("failed to delete retained publish", "error", err, "id", retainedKey(pk.TopicName)) } return } @@ -285,17 +278,14 @@ func (h *Hook) OnRetainMessage(cl *mqtt.Client, pk packets.Packet, r int64) { } err := h.db.Save(in) if err != nil { - h.Log.Error().Err(err). - Str("client", cl.ID). - Interface("data", in). - Msg("failed to save retained publish data") + h.Log.Error("failed to save retained publish data", "error", err, "client", cl.ID, "data", in) } } // OnQosPublish adds or updates an inflight message in the store. func (h *Hook) OnQosPublish(cl *mqtt.Client, pk packets.Packet, sent int64, resends int) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -323,17 +313,14 @@ func (h *Hook) OnQosPublish(cl *mqtt.Client, pk packets.Packet, sent int64, rese err := h.db.Save(in) if err != nil { - h.Log.Error().Err(err). - Str("client", cl.ID). - Interface("data", in). - Msg("failed to save qos inflight data") + h.Log.Error("failed to save qos inflight data", "error", err, "client", cl.ID, "data", in) } } // OnQosComplete removes a resolved inflight message from the store. func (h *Hook) OnQosComplete(cl *mqtt.Client, pk packets.Packet) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -341,16 +328,14 @@ func (h *Hook) OnQosComplete(cl *mqtt.Client, pk packets.Packet) { ID: inflightKey(cl, pk), }) if err != nil { - h.Log.Error().Err(err). - Str("id", inflightKey(cl, pk)). - Msg("failed to delete inflight data") + h.Log.Error("failed to delete inflight data", "error", err, "id", inflightKey(cl, pk)) } } // OnQosDropped removes a dropped inflight message from the store. func (h *Hook) OnQosDropped(cl *mqtt.Client, pk packets.Packet) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) } h.OnQosComplete(cl, pk) @@ -359,7 +344,7 @@ func (h *Hook) OnQosDropped(cl *mqtt.Client, pk packets.Packet) { // OnSysInfoTick stores the latest system info in the store. func (h *Hook) OnSysInfoTick(sys *system.Info) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -371,41 +356,39 @@ func (h *Hook) OnSysInfoTick(sys *system.Info) { err := h.db.Save(in) if err != nil { - h.Log.Error().Err(err). - Interface("data", in). - Msg("failed to save $SYS data") + h.Log.Error("failed to save $SYS data", "error", err, "data", in) } } // OnRetainedExpired deletes expired retained messages from the store. func (h *Hook) OnRetainedExpired(filter string) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } if err := h.db.DeleteStruct(&storage.Message{ID: retainedKey(filter)}); err != nil { - h.Log.Error().Err(err).Str("id", retainedKey(filter)).Msg("failed to delete retained publish") + h.Log.Error("failed to delete retained publish", "error", err, "id", retainedKey(filter)) } } // OnClientExpired deleted expired clients from the store. func (h *Hook) OnClientExpired(cl *mqtt.Client) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } err := h.db.DeleteStruct(&storage.Client{ID: clientKey(cl)}) if err != nil && !errors.Is(err, storm.ErrNotFound) { - h.Log.Error().Err(err).Str("id", clientKey(cl)).Msg("failed to delete expired client") + h.Log.Error("failed to delete expired client", "error", err, "id", clientKey(cl)) } } // StoredClients returns all stored clients from the store. func (h *Hook) StoredClients() (v []storage.Client, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -420,7 +403,7 @@ func (h *Hook) StoredClients() (v []storage.Client, err error) { // StoredSubscriptions returns all stored subscriptions from the store. func (h *Hook) StoredSubscriptions() (v []storage.Subscription, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -435,7 +418,7 @@ func (h *Hook) StoredSubscriptions() (v []storage.Subscription, err error) { // StoredRetainedMessages returns all stored retained messages from the store. func (h *Hook) StoredRetainedMessages() (v []storage.Message, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -450,7 +433,7 @@ func (h *Hook) StoredRetainedMessages() (v []storage.Message, err error) { // StoredInflightMessages returns all stored inflight messages from the store. func (h *Hook) StoredInflightMessages() (v []storage.Message, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -465,7 +448,7 @@ func (h *Hook) StoredInflightMessages() (v []storage.Message, err error) { // StoredSysInfo returns the system info from the store. func (h *Hook) StoredSysInfo() (v storage.SystemInfo, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } diff --git a/hooks/storage/bolt/bolt_test.go b/hooks/storage/bolt/bolt_test.go index b7a04fb7..70695e7c 100644 --- a/hooks/storage/bolt/bolt_test.go +++ b/hooks/storage/bolt/bolt_test.go @@ -5,22 +5,22 @@ package bolt import ( + "log/slog" "os" "testing" "time" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/storage" "github.com/mochi-mqtt/server/v2/packets" "github.com/mochi-mqtt/server/v2/system" "github.com/asdine/storm/v3" - "github.com/rs/zerolog" "github.com/stretchr/testify/require" ) var ( - logger = zerolog.New(os.Stderr).With().Timestamp().Logger().Level(zerolog.Disabled) + logger = slog.New(slog.NewTextHandler(os.Stdout, nil)) client = &mqtt.Client{ ID: "test", @@ -94,7 +94,7 @@ func TestProvides(t *testing.T) { func TestInitBadConfig(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(map[string]any{}) require.Error(t, err) @@ -102,7 +102,7 @@ func TestInitBadConfig(t *testing.T) { func TestInitUseDefaults(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -113,7 +113,7 @@ func TestInitUseDefaults(t *testing.T) { func TestInitBadPath(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(&Options{ Path: "..", }) @@ -122,7 +122,7 @@ func TestInitBadPath(t *testing.T) { func TestOnSessionEstablishedThenOnDisconnect(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -155,13 +155,13 @@ func TestOnSessionEstablishedThenOnDisconnect(t *testing.T) { func TestOnSessionEstablishedNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnSessionEstablished(client, packets.Packet{}) } func TestOnSessionEstablishedClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -170,7 +170,7 @@ func TestOnSessionEstablishedClosedDB(t *testing.T) { func TestOnWillSent(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -189,7 +189,7 @@ func TestOnWillSent(t *testing.T) { func TestOnClientExpired(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -213,7 +213,7 @@ func TestOnClientExpired(t *testing.T) { func TestOnClientExpiredClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -222,19 +222,19 @@ func TestOnClientExpiredClosedDB(t *testing.T) { func TestOnClientExpiredNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnClientExpired(client) } func TestOnDisconnectNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnDisconnect(client, nil, false) } func TestOnDisconnectClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -243,7 +243,7 @@ func TestOnDisconnectClosedDB(t *testing.T) { func TestOnDisconnectSessionTakenOver(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) @@ -266,7 +266,7 @@ func TestOnDisconnectSessionTakenOver(t *testing.T) { func TestOnSubscribedThenOnUnsubscribed(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -288,13 +288,13 @@ func TestOnSubscribedThenOnUnsubscribed(t *testing.T) { func TestOnSubscribedNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnSubscribed(client, pkf, []byte{0}) } func TestOnSubscribedClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -303,13 +303,13 @@ func TestOnSubscribedClosedDB(t *testing.T) { func TestOnUnsubscribedNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnUnsubscribed(client, pkf) } func TestOnUnsubscribedClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -318,7 +318,7 @@ func TestOnUnsubscribedClosedDB(t *testing.T) { func TestOnRetainMessageThenUnset(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -353,7 +353,7 @@ func TestOnRetainMessageThenUnset(t *testing.T) { func TestOnRetainedExpired(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -380,7 +380,7 @@ func TestOnRetainedExpired(t *testing.T) { func TestOnRetainedExpiredClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -389,19 +389,19 @@ func TestOnRetainedExpiredClosedDB(t *testing.T) { func TestOnRetainedExpiredNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnRetainedExpired("a/b/c") } func TestOnRetainMessageNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnRetainMessage(client, packets.Packet{}, 0) } func TestOnRetainMessageClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -410,7 +410,7 @@ func TestOnRetainMessageClosedDB(t *testing.T) { func TestOnQosPublishThenQOSComplete(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -445,13 +445,13 @@ func TestOnQosPublishThenQOSComplete(t *testing.T) { func TestOnQosPublishNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnQosPublish(client, packets.Packet{}, time.Now().Unix(), 0) } func TestOnQosPublishClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -460,13 +460,13 @@ func TestOnQosPublishClosedDB(t *testing.T) { func TestOnQosCompleteNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnQosComplete(client, packets.Packet{}) } func TestOnQosCompleteClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -475,13 +475,13 @@ func TestOnQosCompleteClosedDB(t *testing.T) { func TestOnQosDroppedNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnQosDropped(client, packets.Packet{}) } func TestOnSysInfoTick(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -503,13 +503,13 @@ func TestOnSysInfoTick(t *testing.T) { func TestOnSysInfoTickNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) h.OnSysInfoTick(new(system.Info)) } func TestOnSysInfoTickClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -518,7 +518,7 @@ func TestOnSysInfoTickClosedDB(t *testing.T) { func TestStoredClients(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -543,7 +543,7 @@ func TestStoredClients(t *testing.T) { func TestStoredClientsNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) v, err := h.StoredClients() require.Empty(t, v) require.NoError(t, err) @@ -551,7 +551,7 @@ func TestStoredClientsNoDB(t *testing.T) { func TestStoredClientsClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -562,7 +562,7 @@ func TestStoredClientsClosedDB(t *testing.T) { func TestStoredSubscriptions(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -587,7 +587,7 @@ func TestStoredSubscriptions(t *testing.T) { func TestStoredSubscriptionsNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) v, err := h.StoredSubscriptions() require.Empty(t, v) require.NoError(t, err) @@ -595,7 +595,7 @@ func TestStoredSubscriptionsNoDB(t *testing.T) { func TestStoredSubscriptionsClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -606,7 +606,7 @@ func TestStoredSubscriptionsClosedDB(t *testing.T) { func TestStoredRetainedMessages(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -634,7 +634,7 @@ func TestStoredRetainedMessages(t *testing.T) { func TestStoredRetainedMessagesNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) v, err := h.StoredRetainedMessages() require.Empty(t, v) require.NoError(t, err) @@ -642,7 +642,7 @@ func TestStoredRetainedMessagesNoDB(t *testing.T) { func TestStoredRetainedMessagesClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -653,7 +653,7 @@ func TestStoredRetainedMessagesClosedDB(t *testing.T) { func TestStoredInflightMessages(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -681,7 +681,7 @@ func TestStoredInflightMessages(t *testing.T) { func TestStoredInflightMessagesNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) v, err := h.StoredInflightMessages() require.Empty(t, v) require.NoError(t, err) @@ -689,7 +689,7 @@ func TestStoredInflightMessagesNoDB(t *testing.T) { func TestStoredInflightMessagesClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) @@ -700,7 +700,7 @@ func TestStoredInflightMessagesClosedDB(t *testing.T) { func TestStoredSysInfo(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h.config.Path, h) @@ -722,7 +722,7 @@ func TestStoredSysInfo(t *testing.T) { func TestStoredSysInfoNoDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) v, err := h.StoredSysInfo() require.Empty(t, v) require.NoError(t, err) @@ -730,7 +730,7 @@ func TestStoredSysInfoNoDB(t *testing.T) { func TestStoredSysInfoClosedDB(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) teardown(t, h.config.Path, h) diff --git a/hooks/storage/redis/redis.go b/hooks/storage/redis/redis.go index 72c4a5d3..e7802256 100644 --- a/hooks/storage/redis/redis.go +++ b/hooks/storage/redis/redis.go @@ -10,7 +10,7 @@ import ( "errors" "fmt" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/storage" "github.com/mochi-mqtt/server/v2/packets" "github.com/mochi-mqtt/server/v2/system" @@ -117,12 +117,11 @@ func (h *Hook) Init(config any) error { h.config.HPrefix = defaultHPrefix } - h.Log.Info(). - Str("address", h.config.Options.Addr). - Str("username", h.config.Options.Username). - Int("password-len", len(h.config.Options.Password)). - Int("db", h.config.Options.DB). - Msg("connecting to redis service") + h.Log.Info("connecting to redis service", + "address", h.config.Options.Addr, + "username", h.config.Options.Username, + "password-len", len(h.config.Options.Password), + "db", h.config.Options.DB) h.db = redis.NewClient(h.config.Options) _, err := h.db.Ping(context.Background()).Result() @@ -130,14 +129,15 @@ func (h *Hook) Init(config any) error { return fmt.Errorf("failed to ping service: %w", err) } - h.Log.Info().Msg("connected to redis service") + h.Log.Info("connected to redis service") return nil } // Close closes the redis connection. func (h *Hook) Stop() error { - h.Log.Info().Msg("disconnecting from redis service") + h.Log.Info("disconnecting from redis service") + return h.db.Close() } @@ -155,7 +155,7 @@ func (h *Hook) OnWillSent(cl *mqtt.Client, pk packets.Packet) { // updateClient writes the client data to the store. func (h *Hook) updateClient(cl *mqtt.Client) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -184,14 +184,14 @@ func (h *Hook) updateClient(cl *mqtt.Client) { err := h.db.HSet(h.ctx, h.hKey(storage.ClientKey), clientKey(cl), in).Err() if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to hset client data") + h.Log.Error("failed to hset client data", "error", err, "data", in) } } // OnDisconnect removes a client from the store if they were using a clean session. func (h *Hook) OnDisconnect(cl *mqtt.Client, _ error, expire bool) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -205,14 +205,14 @@ func (h *Hook) OnDisconnect(cl *mqtt.Client, _ error, expire bool) { err := h.db.HDel(h.ctx, h.hKey(storage.ClientKey), clientKey(cl)).Err() if err != nil { - h.Log.Error().Err(err).Str("id", clientKey(cl)).Msg("failed to delete client") + h.Log.Error("failed to delete client", "error", err, "id", clientKey(cl)) } } // OnSubscribed adds one or more client subscriptions to the store. func (h *Hook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []byte) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -232,7 +232,7 @@ func (h *Hook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []by err := h.db.HSet(h.ctx, h.hKey(storage.SubscriptionKey), subscriptionKey(cl, pk.Filters[i].Filter), in).Err() if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to hset subscription data") + h.Log.Error("failed to hset subscription data", "error", err, "data", in) } } } @@ -240,14 +240,14 @@ func (h *Hook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []by // OnUnsubscribed removes one or more client subscriptions from the store. func (h *Hook) OnUnsubscribed(cl *mqtt.Client, pk packets.Packet) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } for i := 0; i < len(pk.Filters); i++ { err := h.db.HDel(h.ctx, h.hKey(storage.SubscriptionKey), subscriptionKey(cl, pk.Filters[i].Filter)).Err() if err != nil { - h.Log.Error().Err(err).Str("id", clientKey(cl)).Msg("failed to delete subscription data") + h.Log.Error("failed to delete subscription data", "error", err, "id", clientKey(cl)) } } } @@ -255,14 +255,14 @@ func (h *Hook) OnUnsubscribed(cl *mqtt.Client, pk packets.Packet) { // OnRetainMessage adds a retained message for a topic to the store. func (h *Hook) OnRetainMessage(cl *mqtt.Client, pk packets.Packet, r int64) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } if r == -1 { err := h.db.HDel(h.ctx, h.hKey(storage.RetainedKey), retainedKey(pk.TopicName)).Err() if err != nil { - h.Log.Error().Err(err).Str("id", clientKey(cl)).Msg("failed to delete retained message data") + h.Log.Error("failed to delete retained message data", "error", err, "id", retainedKey(pk.TopicName)) } return @@ -291,14 +291,14 @@ func (h *Hook) OnRetainMessage(cl *mqtt.Client, pk packets.Packet, r int64) { err := h.db.HSet(h.ctx, h.hKey(storage.RetainedKey), retainedKey(pk.TopicName), in).Err() if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to hset retained message data") + h.Log.Error("failed to hset retained message data", "error", err, "data", in) } } // OnQosPublish adds or updates an inflight message in the store. func (h *Hook) OnQosPublish(cl *mqtt.Client, pk packets.Packet, sent int64, resends int) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -326,27 +326,27 @@ func (h *Hook) OnQosPublish(cl *mqtt.Client, pk packets.Packet, sent int64, rese err := h.db.HSet(h.ctx, h.hKey(storage.InflightKey), inflightKey(cl, pk), in).Err() if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to hset qos inflight message data") + h.Log.Error("failed to hset qos inflight message data", "error", err, "data", in) } } // OnQosComplete removes a resolved inflight message from the store. func (h *Hook) OnQosComplete(cl *mqtt.Client, pk packets.Packet) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } err := h.db.HDel(h.ctx, h.hKey(storage.InflightKey), inflightKey(cl, pk)).Err() if err != nil { - h.Log.Error().Err(err).Str("id", clientKey(cl)).Msg("failed to delete inflight message data") + h.Log.Error("failed to delete qos inflight message data", "error", err, "id", inflightKey(cl, pk)) } } // OnQosDropped removes a dropped inflight message from the store. func (h *Hook) OnQosDropped(cl *mqtt.Client, pk packets.Packet) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) } h.OnQosComplete(cl, pk) @@ -355,7 +355,7 @@ func (h *Hook) OnQosDropped(cl *mqtt.Client, pk packets.Packet) { // OnSysInfoTick stores the latest system info in the store. func (h *Hook) OnSysInfoTick(sys *system.Info) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -367,53 +367,53 @@ func (h *Hook) OnSysInfoTick(sys *system.Info) { err := h.db.HSet(h.ctx, h.hKey(storage.SysInfoKey), sysInfoKey(), in).Err() if err != nil { - h.Log.Error().Err(err).Interface("data", in).Msg("failed to hset server info data") + h.Log.Error("failed to hset server info data", "error", err, "data", in) } } // OnRetainedExpired deletes expired retained messages from the store. func (h *Hook) OnRetainedExpired(filter string) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } err := h.db.HDel(h.ctx, h.hKey(storage.RetainedKey), retainedKey(filter)).Err() if err != nil { - h.Log.Error().Err(err).Str("id", retainedKey(filter)).Msg("failed to delete retained message data") + h.Log.Error("failed to delete expired retained message", "error", err, "id", retainedKey(filter)) } } // OnClientExpired deleted expired clients from the store. func (h *Hook) OnClientExpired(cl *mqtt.Client) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } err := h.db.HDel(h.ctx, h.hKey(storage.ClientKey), clientKey(cl)).Err() if err != nil { - h.Log.Error().Err(err).Str("id", clientKey(cl)).Msg("failed to delete expired client") + h.Log.Error("failed to delete expired client", "error", err, "id", clientKey(cl)) } } // StoredClients returns all stored clients from the store. func (h *Hook) StoredClients() (v []storage.Client, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } rows, err := h.db.HGetAll(h.ctx, h.hKey(storage.ClientKey)).Result() if err != nil && !errors.Is(err, redis.Nil) { - h.Log.Error().Err(err).Msg("failed to HGetAll client data") + h.Log.Error("failed to HGetAll client data", "error", err) return } for _, row := range rows { var d storage.Client if err = d.UnmarshalBinary([]byte(row)); err != nil { - h.Log.Error().Err(err).Str("data", row).Msg("failed to unmarshal client data") + h.Log.Error("failed to unmarshal client data", "error", err, "data", row) } v = append(v, d) @@ -425,20 +425,20 @@ func (h *Hook) StoredClients() (v []storage.Client, err error) { // StoredSubscriptions returns all stored subscriptions from the store. func (h *Hook) StoredSubscriptions() (v []storage.Subscription, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } rows, err := h.db.HGetAll(h.ctx, h.hKey(storage.SubscriptionKey)).Result() if err != nil && !errors.Is(err, redis.Nil) { - h.Log.Error().Err(err).Msg("failed to HGetAll subscription data") + h.Log.Error("failed to HGetAll subscription data", "error", err) return } for _, row := range rows { var d storage.Subscription if err = d.UnmarshalBinary([]byte(row)); err != nil { - h.Log.Error().Err(err).Str("data", row).Msg("failed to unmarshal subscription data") + h.Log.Error("failed to unmarshal subscription data", "error", err, "data", row) } v = append(v, d) @@ -450,20 +450,20 @@ func (h *Hook) StoredSubscriptions() (v []storage.Subscription, err error) { // StoredRetainedMessages returns all stored retained messages from the store. func (h *Hook) StoredRetainedMessages() (v []storage.Message, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } rows, err := h.db.HGetAll(h.ctx, h.hKey(storage.RetainedKey)).Result() if err != nil && !errors.Is(err, redis.Nil) { - h.Log.Error().Err(err).Msg("failed to HGetAll retained message data") + h.Log.Error("failed to HGetAll retained message data", "error", err) return } for _, row := range rows { var d storage.Message if err = d.UnmarshalBinary([]byte(row)); err != nil { - h.Log.Error().Err(err).Str("data", row).Msg("failed to unmarshal retained message data") + h.Log.Error("failed to unmarshal retained message data", "error", err, "data", row) } v = append(v, d) @@ -475,20 +475,20 @@ func (h *Hook) StoredRetainedMessages() (v []storage.Message, err error) { // StoredInflightMessages returns all stored inflight messages from the store. func (h *Hook) StoredInflightMessages() (v []storage.Message, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } rows, err := h.db.HGetAll(h.ctx, h.hKey(storage.InflightKey)).Result() if err != nil && !errors.Is(err, redis.Nil) { - h.Log.Error().Err(err).Msg("failed to HGetAll inflight message data") + h.Log.Error("failed to HGetAll inflight message data", "error", err) return } for _, row := range rows { var d storage.Message if err = d.UnmarshalBinary([]byte(row)); err != nil { - h.Log.Error().Err(err).Str("data", row).Msg("failed to unmarshal inflight message data") + h.Log.Error("failed to unmarshal inflight message data", "error", err, "data", row) } v = append(v, d) @@ -500,7 +500,7 @@ func (h *Hook) StoredInflightMessages() (v []storage.Message, err error) { // StoredSysInfo returns the system info from the store. func (h *Hook) StoredSysInfo() (v storage.SystemInfo, err error) { if h.db == nil { - h.Log.Error().Err(storage.ErrDBFileNotOpen) + h.Log.Error("", "error", storage.ErrDBFileNotOpen) return } @@ -510,7 +510,7 @@ func (h *Hook) StoredSysInfo() (v storage.SystemInfo, err error) { } if err = v.UnmarshalBinary([]byte(row)); err != nil { - h.Log.Error().Err(err).Str("data", row).Msg("failed to unmarshal sys info data") + h.Log.Error("failed to unmarshal sys info data", "error", err, "data", row) } return v, nil diff --git a/hooks/storage/redis/redis_test.go b/hooks/storage/redis/redis_test.go index dbe8af5b..bf3e607b 100644 --- a/hooks/storage/redis/redis_test.go +++ b/hooks/storage/redis/redis_test.go @@ -5,24 +5,24 @@ package redis import ( + "log/slog" "os" "sort" "testing" "time" - "github.com/mochi-mqtt/server/v2" + mqtt "github.com/mochi-mqtt/server/v2" "github.com/mochi-mqtt/server/v2/hooks/storage" "github.com/mochi-mqtt/server/v2/packets" "github.com/mochi-mqtt/server/v2/system" miniredis "github.com/alicebob/miniredis/v2" redis "github.com/go-redis/redis/v8" - "github.com/rs/zerolog" "github.com/stretchr/testify/require" ) var ( - logger = zerolog.New(os.Stderr).With().Timestamp().Logger().Level(zerolog.Disabled) + logger = slog.New(slog.NewTextHandler(os.Stdout, nil)) client = &mqtt.Client{ ID: "test", @@ -41,7 +41,7 @@ var ( func newHook(t *testing.T, addr string) *Hook { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(&Options{ Options: &redis.Options{ @@ -87,13 +87,13 @@ func TestSysInfoKey(t *testing.T) { func TestID(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) require.Equal(t, "redis-db", h.ID()) } func TestProvides(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) require.True(t, h.Provides(mqtt.OnSessionEstablished)) require.True(t, h.Provides(mqtt.OnDisconnect)) require.True(t, h.Provides(mqtt.OnSubscribed)) @@ -116,7 +116,7 @@ func TestHKey(t *testing.T) { s := miniredis.RunT(t) defer s.Close() h := newHook(t, s.Addr()) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) require.Equal(t, defaultHPrefix+"test", h.hKey("test")) } @@ -126,7 +126,7 @@ func TestInitUseDefaults(t *testing.T) { defer s.Close() h := newHook(t, defaultAddr) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(nil) require.NoError(t, err) defer teardown(t, h) @@ -137,7 +137,7 @@ func TestInitUseDefaults(t *testing.T) { func TestInitBadConfig(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(map[string]any{}) require.Error(t, err) @@ -145,7 +145,7 @@ func TestInitBadConfig(t *testing.T) { func TestInitBadAddr(t *testing.T) { h := new(Hook) - h.SetOpts(&logger, nil) + h.SetOpts(logger, nil) err := h.Init(&Options{ Options: &redis.Options{ Addr: "abc:123", diff --git a/hooks_test.go b/hooks_test.go index 4947fa24..bb87accd 100644 --- a/hooks_test.go +++ b/hooks_test.go @@ -215,7 +215,7 @@ func TestHooksAddInitFailure(t *testing.T) { func TestHooksStop(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger err := h.Add(new(HookBase), nil) require.NoError(t, err) @@ -334,7 +334,7 @@ func TestHooksOnUnsubscribe(t *testing.T) { func TestHooksOnPublish(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger hook := new(modifiedHookBase) err := h.Add(hook, nil) @@ -360,7 +360,7 @@ func TestHooksOnPublish(t *testing.T) { func TestHooksOnPacketRead(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger hook := new(modifiedHookBase) err := h.Add(hook, nil) @@ -386,7 +386,7 @@ func TestHooksOnPacketRead(t *testing.T) { func TestHooksOnAuthPacket(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger hook := new(modifiedHookBase) err := h.Add(hook, nil) @@ -404,7 +404,7 @@ func TestHooksOnAuthPacket(t *testing.T) { func TestHooksOnConnect(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger hook := new(modifiedHookBase) err := h.Add(hook, nil) @@ -420,7 +420,7 @@ func TestHooksOnConnect(t *testing.T) { func TestHooksOnPacketEncode(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger hook := new(modifiedHookBase) err := h.Add(hook, nil) @@ -432,7 +432,7 @@ func TestHooksOnPacketEncode(t *testing.T) { func TestHooksOnLWT(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger hook := new(modifiedHookBase) err := h.Add(hook, nil) @@ -449,7 +449,7 @@ func TestHooksOnLWT(t *testing.T) { func TestHooksStoredClients(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger v, err := h.StoredClients() require.NoError(t, err) @@ -471,7 +471,7 @@ func TestHooksStoredClients(t *testing.T) { func TestHooksStoredSubscriptions(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger v, err := h.StoredSubscriptions() require.NoError(t, err) @@ -493,7 +493,7 @@ func TestHooksStoredSubscriptions(t *testing.T) { func TestHooksStoredRetainedMessages(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger v, err := h.StoredRetainedMessages() require.NoError(t, err) @@ -515,7 +515,7 @@ func TestHooksStoredRetainedMessages(t *testing.T) { func TestHooksStoredInflightMessages(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger v, err := h.StoredInflightMessages() require.NoError(t, err) @@ -537,7 +537,7 @@ func TestHooksStoredInflightMessages(t *testing.T) { func TestHooksStoredSysInfo(t *testing.T) { h := new(Hooks) - h.Log = &logger + h.Log = logger v, err := h.StoredSysInfo() require.NoError(t, err) @@ -575,7 +575,7 @@ func TestHookBaseInit(t *testing.T) { func TestHookBaseSetOpts(t *testing.T) { h := new(HookBase) - h.SetOpts(&logger, new(HookOptions)) + h.SetOpts(logger, new(HookOptions)) require.NotNil(t, h.Log) require.NotNil(t, h.Opts) } diff --git a/listeners/http_healthcheck.go b/listeners/http_healthcheck.go index e8fc0274..fb2d2a82 100644 --- a/listeners/http_healthcheck.go +++ b/listeners/http_healthcheck.go @@ -6,23 +6,21 @@ package listeners import ( "context" + "log/slog" "net/http" "sync" "sync/atomic" "time" - - "github.com/rs/zerolog" ) // HTTPHealthCheck is a listener for providing an HTTP healthcheck endpoint. type HTTPHealthCheck struct { sync.RWMutex - id string // the internal id of the listener - address string // the network address to bind to - config *Config // configuration values for the listener - listen *http.Server // the http server - log *zerolog.Logger // server logger - end uint32 // ensure the close methods are only called once + id string // the internal id of the listener + address string // the network address to bind to + config *Config // configuration values for the listener + listen *http.Server // the http server + end uint32 // ensure the close methods are only called once } // NewHTTPHealthCheck initialises and returns a new HTTP listener, listening on an address. @@ -57,9 +55,7 @@ func (l *HTTPHealthCheck) Protocol() string { } // Init initializes the listener. -func (l *HTTPHealthCheck) Init(log *zerolog.Logger) error { - l.log = log - +func (l *HTTPHealthCheck) Init(_ *slog.Logger) error { mux := http.NewServeMux() mux.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { diff --git a/listeners/http_healthcheck_test.go b/listeners/http_healthcheck_test.go index 7362d361..784c892a 100644 --- a/listeners/http_healthcheck_test.go +++ b/listeners/http_healthcheck_test.go @@ -39,13 +39,13 @@ func TestHTTPHealthCheckTLSProtocol(t *testing.T) { TLSConfig: tlsConfigBasic, }) - l.Init(nil) + l.Init(logger) require.Equal(t, "https", l.Protocol()) } func TestHTTPHealthCheckInit(t *testing.T) { l := NewHTTPHealthCheck("healthcheck", testAddr, nil) - err := l.Init(nil) + err := l.Init(logger) require.NoError(t, err) require.NotNil(t, l.listen) @@ -55,7 +55,7 @@ func TestHTTPHealthCheckInit(t *testing.T) { func TestHTTPHealthCheckServeAndClose(t *testing.T) { // setup http stats listener l := NewHTTPHealthCheck("healthcheck", testAddr, nil) - err := l.Init(nil) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) @@ -91,7 +91,7 @@ func TestHTTPHealthCheckServeAndClose(t *testing.T) { func TestHTTPHealthCheckServeAndCloseMethodNotAllowed(t *testing.T) { // setup http stats listener l := NewHTTPHealthCheck("healthcheck", testAddr, nil) - err := l.Init(nil) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) @@ -129,7 +129,7 @@ func TestHTTPHealthCheckServeTLSAndClose(t *testing.T) { TLSConfig: tlsConfigBasic, }) - err := l.Init(nil) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) diff --git a/listeners/http_sysinfo.go b/listeners/http_sysinfo.go index aa32c91c..771716fd 100644 --- a/listeners/http_sysinfo.go +++ b/listeners/http_sysinfo.go @@ -8,26 +8,24 @@ import ( "context" "encoding/json" "io" + "log/slog" "net/http" "sync" "sync/atomic" "time" "github.com/mochi-mqtt/server/v2/system" - - "github.com/rs/zerolog" ) // HTTPStats is a listener for presenting the server $SYS stats on a JSON http endpoint. type HTTPStats struct { sync.RWMutex - id string // the internal id of the listener - address string // the network address to bind to - config *Config // configuration values for the listener - listen *http.Server // the http server - log *zerolog.Logger // server logger - sysInfo *system.Info // pointers to the server data - end uint32 // ensure the close methods are only called once + id string // the internal id of the listener + address string // the network address to bind to + config *Config // configuration values for the listener + listen *http.Server // the http server + sysInfo *system.Info // pointers to the server data + end uint32 // ensure the close methods are only called once } // NewHTTPStats initialises and returns a new HTTP listener, listening on an address. @@ -63,9 +61,7 @@ func (l *HTTPStats) Protocol() string { } // Init initializes the listener. -func (l *HTTPStats) Init(log *zerolog.Logger) error { - l.log = log - +func (l *HTTPStats) Init(_ *slog.Logger) error { mux := http.NewServeMux() mux.HandleFunc("/", l.jsonHandler) l.listen = &http.Server{ diff --git a/listeners/http_sysinfo_test.go b/listeners/http_sysinfo_test.go index 0abbee9f..ffd000cd 100644 --- a/listeners/http_sysinfo_test.go +++ b/listeners/http_sysinfo_test.go @@ -42,14 +42,14 @@ func TestHTTPStatsTLSProtocol(t *testing.T) { TLSConfig: tlsConfigBasic, }, nil) - l.Init(nil) + l.Init(logger) require.Equal(t, "https", l.Protocol()) } func TestHTTPStatsInit(t *testing.T) { sysInfo := new(system.Info) l := NewHTTPStats("t1", testAddr, nil, sysInfo) - err := l.Init(nil) + err := l.Init(logger) require.NoError(t, err) require.NotNil(t, l.sysInfo) @@ -65,7 +65,7 @@ func TestHTTPStatsServeAndClose(t *testing.T) { // setup http stats listener l := NewHTTPStats("t1", testAddr, nil, sysInfo) - err := l.Init(nil) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) @@ -113,7 +113,7 @@ func TestHTTPStatsServeTLSAndClose(t *testing.T) { TLSConfig: tlsConfigBasic, }, sysInfo) - err := l.Init(nil) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) diff --git a/listeners/listeners.go b/listeners/listeners.go index 24031e00..f213d45c 100644 --- a/listeners/listeners.go +++ b/listeners/listeners.go @@ -9,7 +9,7 @@ import ( "net" "sync" - "github.com/rs/zerolog" + "log/slog" ) // Config contains configuration values for a listener. @@ -28,12 +28,12 @@ type CloseFn func(id string) // Listener is an interface for network listeners. A network listener listens // for incoming client connections and adds them to the server. type Listener interface { - Init(*zerolog.Logger) error // open the network address - Serve(EstablishFn) // starting actively listening for new connections - ID() string // return the id of the listener - Address() string // the address of the listener - Protocol() string // the protocol in use by the listener - Close(CloseFn) // stop and close the listener + Init(*slog.Logger) error // open the network address + Serve(EstablishFn) // starting actively listening for new connections + ID() string // return the id of the listener + Address() string // the address of the listener + Protocol() string // the protocol in use by the listener + Close(CloseFn) // stop and close the listener } // Listeners contains the network listeners for the broker. diff --git a/listeners/listeners_test.go b/listeners/listeners_test.go index c6fb5374..63e841ca 100644 --- a/listeners/listeners_test.go +++ b/listeners/listeners_test.go @@ -11,14 +11,15 @@ import ( "testing" "time" - "github.com/rs/zerolog" + "log/slog" + "github.com/stretchr/testify/require" ) const testAddr = ":22222" var ( - logger = zerolog.New(os.Stderr).With().Timestamp().Logger().Level(zerolog.Disabled) + logger = slog.New(slog.NewTextHandler(os.Stdout, nil)) testCertificate = []byte(`-----BEGIN CERTIFICATE----- MIIB/zCCAWgCCQDm3jV+lSF1AzANBgkqhkiG9w0BAQsFADBEMQswCQYDVQQGEwJB diff --git a/listeners/mock.go b/listeners/mock.go index 8847af64..826f80c3 100644 --- a/listeners/mock.go +++ b/listeners/mock.go @@ -9,7 +9,7 @@ import ( "net" "sync" - "github.com/rs/zerolog" + "log/slog" ) // MockEstablisher is a function signature which can be used in testing. @@ -53,7 +53,7 @@ func (l *MockListener) Serve(establisher EstablishFn) { } // Init initializes the listener. -func (l *MockListener) Init(log *zerolog.Logger) error { +func (l *MockListener) Init(log *slog.Logger) error { if l.ErrListen { return fmt.Errorf("listen failure") } diff --git a/listeners/net.go b/listeners/net.go index 662b9ec0..fa4ef3dc 100644 --- a/listeners/net.go +++ b/listeners/net.go @@ -9,16 +9,16 @@ import ( "sync" "sync/atomic" - "github.com/rs/zerolog" + "log/slog" ) // Net is a listener for establishing client connections on basic TCP protocol. type Net struct { // [MQTT-4.2.0-1] mu sync.Mutex - listener net.Listener // a net.Listener which will listen for new clients - id string // the internal id of the listener - log *zerolog.Logger // server logger - end uint32 // ensure the close methods are only called once + listener net.Listener // a net.Listener which will listen for new clients + id string // the internal id of the listener + log *slog.Logger // server logger + end uint32 // ensure the close methods are only called once } // NewNet initialises and returns a listener serving incoming connections on the given net.Listener @@ -45,7 +45,7 @@ func (l *Net) Protocol() string { } // Init initializes the listener. -func (l *Net) Init(log *zerolog.Logger) error { +func (l *Net) Init(log *slog.Logger) error { l.log = log return nil } @@ -67,7 +67,7 @@ func (l *Net) Serve(establish EstablishFn) { go func() { err = establish(l.id, conn) if err != nil { - l.log.Warn().Err(err).Send() + l.log.Warn("", "error", err) } }() } diff --git a/listeners/net_test.go b/listeners/net_test.go index dc8b3099..8afc6668 100644 --- a/listeners/net_test.go +++ b/listeners/net_test.go @@ -46,7 +46,7 @@ func TestNetInit(t *testing.T) { require.NoError(t, err) l := NewNet("t1", n) - err = l.Init(&logger) + err = l.Init(logger) l.Close(MockCloser) require.NoError(t, err) } @@ -56,7 +56,7 @@ func TestNetServeAndClose(t *testing.T) { require.NoError(t, err) l := NewNet("t1", n) - err = l.Init(&logger) + err = l.Init(logger) require.NoError(t, err) o := make(chan bool) @@ -84,7 +84,7 @@ func TestNetEstablishThenEnd(t *testing.T) { require.NoError(t, err) l := NewNet("t1", n) - err = l.Init(&logger) + err = l.Init(logger) require.NoError(t, err) o := make(chan bool) diff --git a/listeners/tcp.go b/listeners/tcp.go index 1fc34da8..1682734a 100644 --- a/listeners/tcp.go +++ b/listeners/tcp.go @@ -10,18 +10,18 @@ import ( "sync" "sync/atomic" - "github.com/rs/zerolog" + "log/slog" ) // TCP is a listener for establishing client connections on basic TCP protocol. type TCP struct { // [MQTT-4.2.0-1] sync.RWMutex - id string // the internal id of the listener - address string // the network address to bind to - listen net.Listener // a net.Listener which will listen for new clients - config *Config // configuration values for the listener - log *zerolog.Logger // server logger - end uint32 // ensure the close methods are only called once + id string // the internal id of the listener + address string // the network address to bind to + listen net.Listener // a net.Listener which will listen for new clients + config *Config // configuration values for the listener + log *slog.Logger // server logger + end uint32 // ensure the close methods are only called once } // NewTCP initialises and returns a new TCP listener, listening on an address. @@ -53,7 +53,7 @@ func (l *TCP) Protocol() string { } // Init initializes the listener. -func (l *TCP) Init(log *zerolog.Logger) error { +func (l *TCP) Init(log *slog.Logger) error { l.log = log var err error @@ -83,7 +83,7 @@ func (l *TCP) Serve(establish EstablishFn) { go func() { err = establish(l.id, conn) if err != nil { - l.log.Warn().Err(err).Send() + l.log.Warn("", "error", err) } }() } diff --git a/listeners/tcp_test.go b/listeners/tcp_test.go index a2b449fe..d1e60023 100644 --- a/listeners/tcp_test.go +++ b/listeners/tcp_test.go @@ -39,21 +39,21 @@ func TestTCPProtocolTLS(t *testing.T) { TLSConfig: tlsConfigBasic, }) - l.Init(&logger) + l.Init(logger) defer l.listen.Close() require.Equal(t, "tcp", l.Protocol()) } func TestTCPInit(t *testing.T) { l := NewTCP("t1", testAddr, nil) - err := l.Init(&logger) + err := l.Init(logger) l.Close(MockCloser) require.NoError(t, err) l2 := NewTCP("t2", testAddr, &Config{ TLSConfig: tlsConfigBasic, }) - err = l2.Init(&logger) + err = l2.Init(logger) l2.Close(MockCloser) require.NoError(t, err) require.NotNil(t, l2.config.TLSConfig) @@ -61,7 +61,7 @@ func TestTCPInit(t *testing.T) { func TestTCPServeAndClose(t *testing.T) { l := NewTCP("t1", testAddr, nil) - err := l.Init(&logger) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) @@ -88,7 +88,7 @@ func TestTCPServeTLSAndClose(t *testing.T) { l := NewTCP("t1", testAddr, &Config{ TLSConfig: tlsConfigBasic, }) - err := l.Init(&logger) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) @@ -110,7 +110,7 @@ func TestTCPServeTLSAndClose(t *testing.T) { func TestTCPEstablishThenEnd(t *testing.T) { l := NewTCP("t1", testAddr, nil) - err := l.Init(&logger) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) diff --git a/listeners/unixsock.go b/listeners/unixsock.go index ebe54c3f..5892fc94 100644 --- a/listeners/unixsock.go +++ b/listeners/unixsock.go @@ -10,17 +10,17 @@ import ( "sync" "sync/atomic" - "github.com/rs/zerolog" + "log/slog" ) // UnixSock is a listener for establishing client connections on basic UnixSock protocol. type UnixSock struct { sync.RWMutex - id string // the internal id of the listener. - address string // the network address to bind to. - listen net.Listener // a net.Listener which will listen for new clients. - log *zerolog.Logger // server logger - end uint32 // ensure the close methods are only called once. + id string // the internal id of the listener. + address string // the network address to bind to. + listen net.Listener // a net.Listener which will listen for new clients. + log *slog.Logger // server logger + end uint32 // ensure the close methods are only called once. } // NewUnixSock initialises and returns a new UnixSock listener, listening on an address. @@ -47,7 +47,7 @@ func (l *UnixSock) Protocol() string { } // Init initializes the listener. -func (l *UnixSock) Init(log *zerolog.Logger) error { +func (l *UnixSock) Init(log *slog.Logger) error { l.log = log var err error @@ -73,7 +73,7 @@ func (l *UnixSock) Serve(establish EstablishFn) { go func() { err = establish(l.id, conn) if err != nil { - l.log.Warn().Err(err).Send() + l.log.Warn("", "error", err) } }() } diff --git a/listeners/unixsock_test.go b/listeners/unixsock_test.go index fe85c164..905b1cc7 100644 --- a/listeners/unixsock_test.go +++ b/listeners/unixsock_test.go @@ -38,19 +38,19 @@ func TestUnixSockProtocol(t *testing.T) { func TestUnixSockInit(t *testing.T) { l := NewUnixSock("t1", testUnixAddr) - err := l.Init(&logger) + err := l.Init(logger) l.Close(MockCloser) require.NoError(t, err) l2 := NewUnixSock("t2", testUnixAddr) - err = l2.Init(&logger) + err = l2.Init(logger) l2.Close(MockCloser) require.NoError(t, err) } func TestUnixSockServeAndClose(t *testing.T) { l := NewUnixSock("t1", testUnixAddr) - err := l.Init(&logger) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) @@ -75,7 +75,7 @@ func TestUnixSockServeAndClose(t *testing.T) { func TestUnixSockEstablishThenEnd(t *testing.T) { l := NewUnixSock("t1", testUnixAddr) - err := l.Init(&logger) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) diff --git a/listeners/websocket.go b/listeners/websocket.go index 0b06c86f..d7934df1 100644 --- a/listeners/websocket.go +++ b/listeners/websocket.go @@ -14,8 +14,9 @@ import ( "sync/atomic" "time" + "log/slog" + "github.com/gorilla/websocket" - "github.com/rs/zerolog" ) var ( @@ -30,7 +31,7 @@ type Websocket struct { // [MQTT-4.2.0-1] address string // the network address to bind to config *Config // configuration values for the listener listen *http.Server // an http server for serving websocket connections - log *zerolog.Logger // server logger + log *slog.Logger // server logger establish EstablishFn // the server's establish connection handler upgrader *websocket.Upgrader // upgrade the incoming http/tcp connection to a websocket compliant connection. end uint32 // ensure the close methods are only called once @@ -75,7 +76,7 @@ func (l *Websocket) Protocol() string { } // Init initializes the listener. -func (l *Websocket) Init(log *zerolog.Logger) error { +func (l *Websocket) Init(log *slog.Logger) error { l.log = log mux := http.NewServeMux() @@ -101,7 +102,7 @@ func (l *Websocket) handler(w http.ResponseWriter, r *http.Request) { err = l.establish(l.id, &wsConn{Conn: c.UnderlyingConn(), c: c}) if err != nil { - l.log.Warn().Err(err).Send() + l.log.Warn("", "error", err) } } diff --git a/listeners/websocket_test.go b/listeners/websocket_test.go index d1f99c67..bcaee728 100644 --- a/listeners/websocket_test.go +++ b/listeners/websocket_test.go @@ -47,14 +47,14 @@ func TestWebsocketProtocoTLS(t *testing.T) { func TestWebsockeInit(t *testing.T) { l := NewWebsocket("t1", testAddr, nil) require.Nil(t, l.listen) - err := l.Init(nil) + err := l.Init(logger) require.NoError(t, err) require.NotNil(t, l.listen) } func TestWebsocketServeAndClose(t *testing.T) { l := NewWebsocket("t1", testAddr, nil) - l.Init(nil) + l.Init(logger) o := make(chan bool) go func(o chan bool) { @@ -77,7 +77,7 @@ func TestWebsocketServeTLSAndClose(t *testing.T) { l := NewWebsocket("t1", testAddr, &Config{ TLSConfig: tlsConfigBasic, }) - err := l.Init(nil) + err := l.Init(logger) require.NoError(t, err) o := make(chan bool) @@ -96,7 +96,7 @@ func TestWebsocketServeTLSAndClose(t *testing.T) { func TestWebsocketUpgrade(t *testing.T) { l := NewWebsocket("t1", testAddr, nil) - l.Init(nil) + l.Init(logger) e := make(chan bool) l.establish = func(id string, c net.Conn) error { diff --git a/server.go b/server.go index 6b611d63..f0235b5d 100644 --- a/server.go +++ b/server.go @@ -22,7 +22,7 @@ import ( "github.com/mochi-mqtt/server/v2/packets" "github.com/mochi-mqtt/server/v2/system" - "github.com/rs/zerolog" + "log/slog" ) const ( @@ -95,9 +95,12 @@ type Options struct { // the servers default logger configuration. If you wish to change the log level, // of the default logger, you can do so by setting // server := mqtt.New(nil) - // l := server.Log.Level(zerolog.DebugLevel) - // server.Log = &l - Logger *zerolog.Logger + // level := new(slog.LevelVar) + // server.Slog = slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ + // Level: level, + // })) + // level.Set(slog.LevelDebug) + Logger *slog.Logger // SysTopicResendInterval specifies the interval between $SYS topic updates in seconds. SysTopicResendInterval int64 @@ -113,7 +116,7 @@ type Server struct { Info *system.Info // values about the server commonly known as $SYS topics loop *loop // loop contains tickers for the system event loop done chan bool // indicate that the server is ending - Log *zerolog.Logger // minimal no-alloc logger + Log *slog.Logger // minimal no-alloc logger hooks *Hooks // hooks contains hooks for extra functionality such as auth and persistent storage. } @@ -129,10 +132,10 @@ type loop struct { // ops contains server values which can be propagated to other structs. type ops struct { - options *Options // a pointer to the server options and capabilities, for referencing in clients - info *system.Info // pointers to server system info - hooks *Hooks // pointer to the server hooks - log *zerolog.Logger // a structured logger for the client + options *Options // a pointer to the server options and capabilities, for referencing in clients + info *system.Info // pointers to server system info + hooks *Hooks // pointer to the server hooks + log *slog.Logger // a structured logger for the client } // New returns a new instance of mochi mqtt broker. Optional parameters @@ -192,8 +195,8 @@ func (o *Options) ensureDefaults() { } if o.Logger == nil { - log := zerolog.New(os.Stderr).With().Timestamp().Logger().Level(zerolog.InfoLevel).Output(zerolog.ConsoleWriter{Out: os.Stderr}) - o.Logger = &log + log := slog.New(slog.NewTextHandler(os.Stdout, nil)) + o.Logger = log } } @@ -227,12 +230,12 @@ func (s *Server) NewClient(c net.Conn, listener string, id string, inline bool) // AddHook attaches a new Hook to the server. Ideally, this should be called // before the server is started with s.Serve(). func (s *Server) AddHook(hook Hook, config any) error { - nl := s.Log.With().Str("hook", hook.ID()).Logger() - hook.SetOpts(&nl, &HookOptions{ + nl := s.Log.With("hook", hook.ID()) + hook.SetOpts(nl, &HookOptions{ Capabilities: s.Options.Capabilities, }) - s.Log.Info().Str("hook", hook.ID()).Msg("added hook") + s.Log.Info("added hook", "hook", hook.ID()) return s.hooks.Add(hook, config) } @@ -242,23 +245,23 @@ func (s *Server) AddListener(l listeners.Listener) error { return ErrListenerIDExists } - nl := s.Log.With().Str("listener", l.ID()).Logger() - err := l.Init(&nl) + nl := s.Log.With(slog.String("listener", l.ID())) + err := l.Init(nl) if err != nil { return err } s.Listeners.Add(l) - s.Log.Info().Str("id", l.ID()).Str("protocol", l.Protocol()).Str("address", l.Address()).Msg("attached listener") + s.Log.Info("attached listener", "id", l.ID(), "protocol", l.Protocol(), "address", l.Address()) return nil } // Serve starts the event loops responsible for establishing client connections // on all attached listeners, publishing the system topics, and starting all hooks. func (s *Server) Serve() error { - s.Log.Info().Str("version", Version).Msg("mochi mqtt starting") - defer s.Log.Info().Msg("mochi mqtt server started") + s.Log.Info("mochi mqtt starting", "version", Version) + defer s.Log.Info("mochi mqtt server started") if s.hooks.Provides( StoredClients, @@ -283,8 +286,8 @@ func (s *Server) Serve() error { // eventLoop loops forever, running various server housekeeping methods at different intervals. func (s *Server) eventLoop() { - s.Log.Debug().Msg("system event loop started") - defer s.Log.Debug().Msg("system event loop halted") + s.Log.Debug("system event loop started") + defer s.Log.Debug("system event loop halted") for { select { @@ -375,8 +378,8 @@ func (s *Server) attachClient(cl *Client, listener string) error { } else { cl.Properties.Will = Will{} // [MQTT-3.14.4-3] [MQTT-3.1.2-10] } + s.Log.Debug("client disconnected", "error", err, "client", cl.ID, "remote", cl.Net.Remote, "listener", listener) - s.Log.Debug().Str("client", cl.ID).Err(err).Str("remote", cl.Net.Remote).Str("listener", listener).Msg("client disconnected") expire := (cl.Properties.ProtocolVersion == 5 && cl.Properties.Props.SessionExpiryInterval == 0) || (cl.Properties.ProtocolVersion < 5 && cl.Properties.Clean) s.hooks.OnDisconnect(cl, err, expire) @@ -421,7 +424,7 @@ func (s *Server) receivePacket(cl *Client, pk packets.Packet) error { s.DisconnectClient(cl, code) } - s.Log.Warn().Err(err).Str("client", cl.ID).Str("listener", cl.Net.Listener).Interface("pk", pk).Msg("error processing packet") + s.Log.Warn("error processing packet", "error", err, "client", cl.ID, "listener", cl.Net.Listener, "pk", pk) return err } @@ -485,10 +488,8 @@ func (s *Server) inheritClientSession(pk packets.Packet, cl *Client) bool { // from increasing memory usage by inflights + subs * client-id. s.UnsubscribeClient(existing) existing.ClearInflights(math.MaxInt64, 0) - s.Log.Debug().Str("client", cl.ID). - Str("old_remote", existing.Net.Remote). - Str("new_remote", cl.Net.Remote). - Msg("session taken over") + + s.Log.Debug("session taken over", "client", cl.ID, "old_remote", existing.Net.Remote, "new_remote", cl.Net.Remote) return true // [MQTT-3.2.2-3] } @@ -812,7 +813,7 @@ func (s *Server) publishToSubscribers(pk packets.Packet) { if cl, ok := s.Clients.Get(id); ok { _, err := s.publishToClient(cl, subs, pk) if err != nil { - s.Log.Debug().Err(err).Str("client", cl.ID).Interface("packet", pk).Msg("failed publishing packet") + s.Log.Debug("failed publishing packet", "error", err, "client", cl.ID, "packet", pk) } } } @@ -862,7 +863,7 @@ func (s *Server) publishToClient(cl *Client, sub packets.Subscription, pk packet i, err := cl.NextPacketID() // [MQTT-4.3.2-1] [MQTT-4.3.3-1] if err != nil { s.hooks.OnPacketIDExhausted(cl, pk) - s.Log.Warn().Err(err).Str("client", cl.ID).Str("listener", cl.Net.Listener).Msg("packet ids exhausted") + s.Log.Warn("packet ids exhausted", "error", err, "client", cl.ID, "listener", cl.Net.Listener) return out, packets.ErrQuotaExceeded } @@ -913,7 +914,7 @@ func (s *Server) publishRetainedToClient(cl *Client, sub packets.Subscription, e for _, pkv := range s.Topics.Messages(sub.Filter) { // [MQTT-3.8.4-4] _, err := s.publishToClient(cl, sub, pkv) if err != nil { - s.Log.Debug().Err(err).Str("client", cl.ID).Str("listener", cl.Net.Listener).Interface("packet", pkv).Msg("failed to publish retained message") + s.Log.Debug("failed to publish retained message", "error", err, "client", cl.ID, "listener", cl.Net.Listener, "packet", pkv) continue } s.hooks.OnRetainPublished(cl, pkv) @@ -1281,7 +1282,7 @@ func (s *Server) Close() error { s.hooks.OnStopped() s.hooks.Stop() - s.Log.Info().Msg("mochi mqtt server stopped") + s.Log.Info("mochi mqtt server stopped") return nil } @@ -1340,9 +1341,7 @@ func (s *Server) readStore() error { return fmt.Errorf("failed to load clients; %w", err) } s.loadClients(clients) - s.Log.Debug(). - Int("len", len(clients)). - Msg("loaded clients from store") + s.Log.Debug("loaded clients from store", "len", len(clients)) } if s.hooks.Provides(StoredSubscriptions) { @@ -1351,9 +1350,7 @@ func (s *Server) readStore() error { return fmt.Errorf("load subscriptions; %w", err) } s.loadSubscriptions(subs) - s.Log.Debug(). - Int("len", len(subs)). - Msg("loaded subscriptions from store") + s.Log.Debug("loaded subscriptions from store", "len", len(subs)) } if s.hooks.Provides(StoredInflightMessages) { @@ -1362,9 +1359,7 @@ func (s *Server) readStore() error { return fmt.Errorf("load inflight; %w", err) } s.loadInflight(inflight) - s.Log.Debug(). - Int("len", len(inflight)). - Msg("loaded inflights from store") + s.Log.Debug("loaded inflights from store", "len", len(inflight)) } if s.hooks.Provides(StoredRetainedMessages) { @@ -1373,9 +1368,7 @@ func (s *Server) readStore() error { return fmt.Errorf("load retained; %w", err) } s.loadRetained(retained) - s.Log.Debug(). - Int("len", len(retained)). - Msg("loaded retained messages from store") + s.Log.Debug("loaded retained messages from store", "len", len(retained)) } if s.hooks.Provides(StoredSysInfo) { @@ -1384,8 +1377,7 @@ func (s *Server) readStore() error { return fmt.Errorf("load server info; %w", err) } s.loadServerInfo(sysInfo.Info) - s.Log.Debug(). - Msg("loaded $SYS info from store") + s.Log.Debug("loaded $SYS info from store") } return nil diff --git a/server_test.go b/server_test.go index b9f35fa8..e9ea8375 100644 --- a/server_test.go +++ b/server_test.go @@ -8,6 +8,7 @@ import ( "bytes" "encoding/binary" "io" + "log/slog" "net" "os" "strconv" @@ -20,11 +21,10 @@ import ( "github.com/mochi-mqtt/server/v2/packets" "github.com/mochi-mqtt/server/v2/system" - "github.com/rs/zerolog" "github.com/stretchr/testify/require" ) -var logger = zerolog.New(os.Stderr).With().Timestamp().Logger().Level(zerolog.Disabled) +var logger = slog.New(slog.NewTextHandler(os.Stdout, nil)) type ProtocolTest []struct { protocolVersion byte @@ -37,6 +37,11 @@ type AllowHook struct { HookBase } +func (h *AllowHook) SetOpts(l *slog.Logger, opts *HookOptions) { + h.Log = l + h.Opts = opts +} + func (h *AllowHook) ID() string { return "allow-all-auth" } @@ -53,6 +58,11 @@ type DelayHook struct { DisconnectDelay time.Duration } +func (h *DelayHook) SetOpts(l *slog.Logger, opts *HookOptions) { + h.Log = l + h.Opts = opts +} + func (h *DelayHook) ID() string { return "delay-hook" } @@ -71,9 +81,10 @@ func newServer() *Server { cc.ReceiveMaximum = 0 s := New(&Options{ - Logger: &logger, + Logger: logger, Capabilities: &cc, }) + s.AddHook(new(AllowHook), nil) return s } @@ -116,7 +127,7 @@ func TestNewNilOpts(t *testing.T) { func TestServerNewClient(t *testing.T) { s := New(nil) - s.Log = &logger + s.Log = logger r, _ := net.Pipe() cl := s.NewClient(r, "testing", "test", false) @@ -143,7 +154,8 @@ func TestServerNewClientInline(t *testing.T) { func TestServerAddHook(t *testing.T) { s := New(nil) - s.Log = &logger + + s.Log = logger require.NotNil(t, s) require.Equal(t, int64(0), s.hooks.Len()) @@ -662,7 +674,7 @@ func TestEstablishConnectionInheritExistingClean(t *testing.T) { func TestEstablishConnectionBadAuthentication(t *testing.T) { s := New(&Options{ - Logger: &logger, + Logger: logger, }) defer s.Close() @@ -696,7 +708,7 @@ func TestEstablishConnectionBadAuthentication(t *testing.T) { func TestEstablishConnectionBadAuthenticationAckFailure(t *testing.T) { s := New(&Options{ - Logger: &logger, + Logger: logger, }) defer s.Close() @@ -1283,10 +1295,10 @@ func TestServerProcessPublishAckFailure(t *testing.T) { func TestServerProcessPublishOnPublishAckErrorRWError(t *testing.T) { s := newServer() hook := new(modifiedHookBase) - hook.fail = true + hook.fail = true hook.err = packets.ErrUnspecifiedError - err := s.AddHook(hook, nil) - require.NoError(t,err) + err := s.AddHook(hook, nil) + require.NoError(t, err) cl, _, w := newTestClient() cl.Properties.ProtocolVersion = 5 @@ -1301,10 +1313,10 @@ func TestServerProcessPublishOnPublishAckErrorRWError(t *testing.T) { func TestServerProcessPublishOnPublishAckErrorContinue(t *testing.T) { s := newServer() hook := new(modifiedHookBase) - hook.fail = true - hook.err = packets.ErrPayloadFormatInvalid - err := s.AddHook(hook, nil) - require.NoError(t,err) + hook.fail = true + hook.err = packets.ErrPayloadFormatInvalid + err := s.AddHook(hook, nil) + require.NoError(t, err) s.Serve() defer s.Close() @@ -1326,10 +1338,10 @@ func TestServerProcessPublishOnPublishAckErrorContinue(t *testing.T) { func TestServerProcessPublishOnPublishPkIgnore(t *testing.T) { s := newServer() hook := new(modifiedHookBase) - hook.fail = true - hook.err = packets.CodeSuccessIgnore - err := s.AddHook(hook, nil) - require.NoError(t,err) + hook.fail = true + hook.err = packets.CodeSuccessIgnore + err := s.AddHook(hook, nil) + require.NoError(t, err) s.Serve() defer s.Close() @@ -1337,20 +1349,19 @@ func TestServerProcessPublishOnPublishPkIgnore(t *testing.T) { s.Clients.Add(cl) receiver, r2, w2 := newTestClient() - receiver.ID = "receiver" - s.Clients.Add(receiver) - s.Topics.Subscribe(receiver.ID, packets.Subscription{Filter: "a/b/c"}) - - require.Equal(t, int64(0), atomic.LoadInt64(&s.Info.PacketsReceived)) - require.Equal(t, 0, len(s.Topics.Messages("a/b/c"))) + receiver.ID = "receiver" + s.Clients.Add(receiver) + s.Topics.Subscribe(receiver.ID, packets.Subscription{Filter: "a/b/c"}) - receiverBuf := make(chan []byte) - go func() { - buf, err := io.ReadAll(r2) - require.NoError(t, err) - receiverBuf <- buf - }() + require.Equal(t, int64(0), atomic.LoadInt64(&s.Info.PacketsReceived)) + require.Equal(t, 0, len(s.Topics.Messages("a/b/c"))) + receiverBuf := make(chan []byte) + go func() { + buf, err := io.ReadAll(r2) + require.NoError(t, err) + receiverBuf <- buf + }() go func() { err := s.processPacket(cl, *packets.TPacketData[packets.Publish].Get(packets.TPublishQos1).Packet) @@ -1399,7 +1410,7 @@ func TestServerProcessPublishInvalidTopic(t *testing.T) { func TestServerProcessPublishACLCheckDeny(t *testing.T) { s := New(&Options{ - Logger: &logger, + Logger: logger, }) s.Serve() defer s.Close() @@ -1523,7 +1534,6 @@ func TestServerProcessPacketPublishDowngradeQos(t *testing.T) { require.Equal(t, packets.TPacketData[packets.Puback].Get(packets.TPuback).RawBytes, buf) } - func TestPublishToSubscribersSelfNoLocal(t *testing.T) { s := newServer() cl, r, w := newTestClient() @@ -1693,7 +1703,6 @@ func TestPublishToSubscribersPkIgnore(t *testing.T) { require.Equal(t, []byte{}, <-receiverBuf) } - func TestPublishToClientServerDowngradeQos(t *testing.T) { s := newServer() s.Options.Capabilities.MaximumQos = 1 @@ -1759,7 +1768,7 @@ func TestPublishToClientExceedClientWritesPending(t *testing.T) { cl := newClient(w, &ops{ info: new(system.Info), hooks: new(Hooks), - log: &logger, + log: logger, options: &Options{ Capabilities: &Capabilities{ MaximumClientWritesPending: 3, @@ -2003,7 +2012,6 @@ func TestNoRetainMessageIfUnavailable(t *testing.T) { require.Equal(t, int64(0), atomic.LoadInt64(&s.Info.Retained)) } - func TestNoRetainMessageIfPkIgnore(t *testing.T) { s := newServer() cl, _, _ := newTestClient() @@ -2020,7 +2028,7 @@ func TestNoRetainMessage(t *testing.T) { cl, _, _ := newTestClient() s.Clients.Add(cl) - s.retainMessage(new(Client), *packets.TPacketData[packets.Publish].Get(packets.TPublishRetain).Packet) + s.retainMessage(new(Client), *packets.TPacketData[packets.Publish].Get(packets.TPublishRetain).Packet) require.Equal(t, int64(1), atomic.LoadInt64(&s.Info.Retained)) } @@ -2604,7 +2612,7 @@ func TestServerProcessSubscribeNoConnection(t *testing.T) { func TestServerProcessSubscribeACLCheckDeny(t *testing.T) { s := New(&Options{ - Logger: &logger, + Logger: logger, }) s.Serve() cl, r, w := newTestClient() @@ -2623,7 +2631,7 @@ func TestServerProcessSubscribeACLCheckDeny(t *testing.T) { func TestServerProcessSubscribeACLCheckDenyObscure(t *testing.T) { s := New(&Options{ - Logger: &logger, + Logger: logger, }) s.Serve() s.Options.Capabilities.Compatibilities.ObscureNotAuthorized = true diff --git a/vendor/github.com/mattn/go-colorable/LICENSE b/vendor/github.com/mattn/go-colorable/LICENSE deleted file mode 100644 index 91b5cef3..00000000 --- a/vendor/github.com/mattn/go-colorable/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Yasuhiro Matsumoto - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/mattn/go-colorable/README.md b/vendor/github.com/mattn/go-colorable/README.md deleted file mode 100644 index ca048371..00000000 --- a/vendor/github.com/mattn/go-colorable/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# go-colorable - -[![Build Status](https://github.com/mattn/go-colorable/workflows/test/badge.svg)](https://github.com/mattn/go-colorable/actions?query=workflow%3Atest) -[![Codecov](https://codecov.io/gh/mattn/go-colorable/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-colorable) -[![GoDoc](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable) -[![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable) - -Colorable writer for windows. - -For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.) -This package is possible to handle escape sequence for ansi color on windows. - -## Too Bad! - -![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png) - - -## So Good! - -![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png) - -## Usage - -```go -logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) -logrus.SetOutput(colorable.NewColorableStdout()) - -logrus.Info("succeeded") -logrus.Warn("not correct") -logrus.Error("something error") -logrus.Fatal("panic") -``` - -You can compile above code on non-windows OSs. - -## Installation - -``` -$ go get github.com/mattn/go-colorable -``` - -# License - -MIT - -# Author - -Yasuhiro Matsumoto (a.k.a mattn) diff --git a/vendor/github.com/mattn/go-colorable/colorable_appengine.go b/vendor/github.com/mattn/go-colorable/colorable_appengine.go deleted file mode 100644 index 416d1bbb..00000000 --- a/vendor/github.com/mattn/go-colorable/colorable_appengine.go +++ /dev/null @@ -1,38 +0,0 @@ -//go:build appengine -// +build appengine - -package colorable - -import ( - "io" - "os" - - _ "github.com/mattn/go-isatty" -) - -// NewColorable returns new instance of Writer which handles escape sequence. -func NewColorable(file *os.File) io.Writer { - if file == nil { - panic("nil passed instead of *os.File to NewColorable()") - } - - return file -} - -// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout. -func NewColorableStdout() io.Writer { - return os.Stdout -} - -// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. -func NewColorableStderr() io.Writer { - return os.Stderr -} - -// EnableColorsStdout enable colors if possible. -func EnableColorsStdout(enabled *bool) func() { - if enabled != nil { - *enabled = true - } - return func() {} -} diff --git a/vendor/github.com/mattn/go-colorable/colorable_others.go b/vendor/github.com/mattn/go-colorable/colorable_others.go deleted file mode 100644 index 766d9460..00000000 --- a/vendor/github.com/mattn/go-colorable/colorable_others.go +++ /dev/null @@ -1,38 +0,0 @@ -//go:build !windows && !appengine -// +build !windows,!appengine - -package colorable - -import ( - "io" - "os" - - _ "github.com/mattn/go-isatty" -) - -// NewColorable returns new instance of Writer which handles escape sequence. -func NewColorable(file *os.File) io.Writer { - if file == nil { - panic("nil passed instead of *os.File to NewColorable()") - } - - return file -} - -// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout. -func NewColorableStdout() io.Writer { - return os.Stdout -} - -// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. -func NewColorableStderr() io.Writer { - return os.Stderr -} - -// EnableColorsStdout enable colors if possible. -func EnableColorsStdout(enabled *bool) func() { - if enabled != nil { - *enabled = true - } - return func() {} -} diff --git a/vendor/github.com/mattn/go-colorable/colorable_windows.go b/vendor/github.com/mattn/go-colorable/colorable_windows.go deleted file mode 100644 index 1846ad5a..00000000 --- a/vendor/github.com/mattn/go-colorable/colorable_windows.go +++ /dev/null @@ -1,1047 +0,0 @@ -//go:build windows && !appengine -// +build windows,!appengine - -package colorable - -import ( - "bytes" - "io" - "math" - "os" - "strconv" - "strings" - "sync" - "syscall" - "unsafe" - - "github.com/mattn/go-isatty" -) - -const ( - foregroundBlue = 0x1 - foregroundGreen = 0x2 - foregroundRed = 0x4 - foregroundIntensity = 0x8 - foregroundMask = (foregroundRed | foregroundBlue | foregroundGreen | foregroundIntensity) - backgroundBlue = 0x10 - backgroundGreen = 0x20 - backgroundRed = 0x40 - backgroundIntensity = 0x80 - backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity) - commonLvbUnderscore = 0x8000 - - cENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4 -) - -const ( - genericRead = 0x80000000 - genericWrite = 0x40000000 -) - -const ( - consoleTextmodeBuffer = 0x1 -) - -type wchar uint16 -type short int16 -type dword uint32 -type word uint16 - -type coord struct { - x short - y short -} - -type smallRect struct { - left short - top short - right short - bottom short -} - -type consoleScreenBufferInfo struct { - size coord - cursorPosition coord - attributes word - window smallRect - maximumWindowSize coord -} - -type consoleCursorInfo struct { - size dword - visible int32 -} - -var ( - kernel32 = syscall.NewLazyDLL("kernel32.dll") - procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") - procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute") - procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition") - procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW") - procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute") - procGetConsoleCursorInfo = kernel32.NewProc("GetConsoleCursorInfo") - procSetConsoleCursorInfo = kernel32.NewProc("SetConsoleCursorInfo") - procSetConsoleTitle = kernel32.NewProc("SetConsoleTitleW") - procGetConsoleMode = kernel32.NewProc("GetConsoleMode") - procSetConsoleMode = kernel32.NewProc("SetConsoleMode") - procCreateConsoleScreenBuffer = kernel32.NewProc("CreateConsoleScreenBuffer") -) - -// Writer provides colorable Writer to the console -type Writer struct { - out io.Writer - handle syscall.Handle - althandle syscall.Handle - oldattr word - oldpos coord - rest bytes.Buffer - mutex sync.Mutex -} - -// NewColorable returns new instance of Writer which handles escape sequence from File. -func NewColorable(file *os.File) io.Writer { - if file == nil { - panic("nil passed instead of *os.File to NewColorable()") - } - - if isatty.IsTerminal(file.Fd()) { - var mode uint32 - if r, _, _ := procGetConsoleMode.Call(file.Fd(), uintptr(unsafe.Pointer(&mode))); r != 0 && mode&cENABLE_VIRTUAL_TERMINAL_PROCESSING != 0 { - return file - } - var csbi consoleScreenBufferInfo - handle := syscall.Handle(file.Fd()) - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - return &Writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}} - } - return file -} - -// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout. -func NewColorableStdout() io.Writer { - return NewColorable(os.Stdout) -} - -// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. -func NewColorableStderr() io.Writer { - return NewColorable(os.Stderr) -} - -var color256 = map[int]int{ - 0: 0x000000, - 1: 0x800000, - 2: 0x008000, - 3: 0x808000, - 4: 0x000080, - 5: 0x800080, - 6: 0x008080, - 7: 0xc0c0c0, - 8: 0x808080, - 9: 0xff0000, - 10: 0x00ff00, - 11: 0xffff00, - 12: 0x0000ff, - 13: 0xff00ff, - 14: 0x00ffff, - 15: 0xffffff, - 16: 0x000000, - 17: 0x00005f, - 18: 0x000087, - 19: 0x0000af, - 20: 0x0000d7, - 21: 0x0000ff, - 22: 0x005f00, - 23: 0x005f5f, - 24: 0x005f87, - 25: 0x005faf, - 26: 0x005fd7, - 27: 0x005fff, - 28: 0x008700, - 29: 0x00875f, - 30: 0x008787, - 31: 0x0087af, - 32: 0x0087d7, - 33: 0x0087ff, - 34: 0x00af00, - 35: 0x00af5f, - 36: 0x00af87, - 37: 0x00afaf, - 38: 0x00afd7, - 39: 0x00afff, - 40: 0x00d700, - 41: 0x00d75f, - 42: 0x00d787, - 43: 0x00d7af, - 44: 0x00d7d7, - 45: 0x00d7ff, - 46: 0x00ff00, - 47: 0x00ff5f, - 48: 0x00ff87, - 49: 0x00ffaf, - 50: 0x00ffd7, - 51: 0x00ffff, - 52: 0x5f0000, - 53: 0x5f005f, - 54: 0x5f0087, - 55: 0x5f00af, - 56: 0x5f00d7, - 57: 0x5f00ff, - 58: 0x5f5f00, - 59: 0x5f5f5f, - 60: 0x5f5f87, - 61: 0x5f5faf, - 62: 0x5f5fd7, - 63: 0x5f5fff, - 64: 0x5f8700, - 65: 0x5f875f, - 66: 0x5f8787, - 67: 0x5f87af, - 68: 0x5f87d7, - 69: 0x5f87ff, - 70: 0x5faf00, - 71: 0x5faf5f, - 72: 0x5faf87, - 73: 0x5fafaf, - 74: 0x5fafd7, - 75: 0x5fafff, - 76: 0x5fd700, - 77: 0x5fd75f, - 78: 0x5fd787, - 79: 0x5fd7af, - 80: 0x5fd7d7, - 81: 0x5fd7ff, - 82: 0x5fff00, - 83: 0x5fff5f, - 84: 0x5fff87, - 85: 0x5fffaf, - 86: 0x5fffd7, - 87: 0x5fffff, - 88: 0x870000, - 89: 0x87005f, - 90: 0x870087, - 91: 0x8700af, - 92: 0x8700d7, - 93: 0x8700ff, - 94: 0x875f00, - 95: 0x875f5f, - 96: 0x875f87, - 97: 0x875faf, - 98: 0x875fd7, - 99: 0x875fff, - 100: 0x878700, - 101: 0x87875f, - 102: 0x878787, - 103: 0x8787af, - 104: 0x8787d7, - 105: 0x8787ff, - 106: 0x87af00, - 107: 0x87af5f, - 108: 0x87af87, - 109: 0x87afaf, - 110: 0x87afd7, - 111: 0x87afff, - 112: 0x87d700, - 113: 0x87d75f, - 114: 0x87d787, - 115: 0x87d7af, - 116: 0x87d7d7, - 117: 0x87d7ff, - 118: 0x87ff00, - 119: 0x87ff5f, - 120: 0x87ff87, - 121: 0x87ffaf, - 122: 0x87ffd7, - 123: 0x87ffff, - 124: 0xaf0000, - 125: 0xaf005f, - 126: 0xaf0087, - 127: 0xaf00af, - 128: 0xaf00d7, - 129: 0xaf00ff, - 130: 0xaf5f00, - 131: 0xaf5f5f, - 132: 0xaf5f87, - 133: 0xaf5faf, - 134: 0xaf5fd7, - 135: 0xaf5fff, - 136: 0xaf8700, - 137: 0xaf875f, - 138: 0xaf8787, - 139: 0xaf87af, - 140: 0xaf87d7, - 141: 0xaf87ff, - 142: 0xafaf00, - 143: 0xafaf5f, - 144: 0xafaf87, - 145: 0xafafaf, - 146: 0xafafd7, - 147: 0xafafff, - 148: 0xafd700, - 149: 0xafd75f, - 150: 0xafd787, - 151: 0xafd7af, - 152: 0xafd7d7, - 153: 0xafd7ff, - 154: 0xafff00, - 155: 0xafff5f, - 156: 0xafff87, - 157: 0xafffaf, - 158: 0xafffd7, - 159: 0xafffff, - 160: 0xd70000, - 161: 0xd7005f, - 162: 0xd70087, - 163: 0xd700af, - 164: 0xd700d7, - 165: 0xd700ff, - 166: 0xd75f00, - 167: 0xd75f5f, - 168: 0xd75f87, - 169: 0xd75faf, - 170: 0xd75fd7, - 171: 0xd75fff, - 172: 0xd78700, - 173: 0xd7875f, - 174: 0xd78787, - 175: 0xd787af, - 176: 0xd787d7, - 177: 0xd787ff, - 178: 0xd7af00, - 179: 0xd7af5f, - 180: 0xd7af87, - 181: 0xd7afaf, - 182: 0xd7afd7, - 183: 0xd7afff, - 184: 0xd7d700, - 185: 0xd7d75f, - 186: 0xd7d787, - 187: 0xd7d7af, - 188: 0xd7d7d7, - 189: 0xd7d7ff, - 190: 0xd7ff00, - 191: 0xd7ff5f, - 192: 0xd7ff87, - 193: 0xd7ffaf, - 194: 0xd7ffd7, - 195: 0xd7ffff, - 196: 0xff0000, - 197: 0xff005f, - 198: 0xff0087, - 199: 0xff00af, - 200: 0xff00d7, - 201: 0xff00ff, - 202: 0xff5f00, - 203: 0xff5f5f, - 204: 0xff5f87, - 205: 0xff5faf, - 206: 0xff5fd7, - 207: 0xff5fff, - 208: 0xff8700, - 209: 0xff875f, - 210: 0xff8787, - 211: 0xff87af, - 212: 0xff87d7, - 213: 0xff87ff, - 214: 0xffaf00, - 215: 0xffaf5f, - 216: 0xffaf87, - 217: 0xffafaf, - 218: 0xffafd7, - 219: 0xffafff, - 220: 0xffd700, - 221: 0xffd75f, - 222: 0xffd787, - 223: 0xffd7af, - 224: 0xffd7d7, - 225: 0xffd7ff, - 226: 0xffff00, - 227: 0xffff5f, - 228: 0xffff87, - 229: 0xffffaf, - 230: 0xffffd7, - 231: 0xffffff, - 232: 0x080808, - 233: 0x121212, - 234: 0x1c1c1c, - 235: 0x262626, - 236: 0x303030, - 237: 0x3a3a3a, - 238: 0x444444, - 239: 0x4e4e4e, - 240: 0x585858, - 241: 0x626262, - 242: 0x6c6c6c, - 243: 0x767676, - 244: 0x808080, - 245: 0x8a8a8a, - 246: 0x949494, - 247: 0x9e9e9e, - 248: 0xa8a8a8, - 249: 0xb2b2b2, - 250: 0xbcbcbc, - 251: 0xc6c6c6, - 252: 0xd0d0d0, - 253: 0xdadada, - 254: 0xe4e4e4, - 255: 0xeeeeee, -} - -// `\033]0;TITLESTR\007` -func doTitleSequence(er *bytes.Reader) error { - var c byte - var err error - - c, err = er.ReadByte() - if err != nil { - return err - } - if c != '0' && c != '2' { - return nil - } - c, err = er.ReadByte() - if err != nil { - return err - } - if c != ';' { - return nil - } - title := make([]byte, 0, 80) - for { - c, err = er.ReadByte() - if err != nil { - return err - } - if c == 0x07 || c == '\n' { - break - } - title = append(title, c) - } - if len(title) > 0 { - title8, err := syscall.UTF16PtrFromString(string(title)) - if err == nil { - procSetConsoleTitle.Call(uintptr(unsafe.Pointer(title8))) - } - } - return nil -} - -// returns Atoi(s) unless s == "" in which case it returns def -func atoiWithDefault(s string, def int) (int, error) { - if s == "" { - return def, nil - } - return strconv.Atoi(s) -} - -// Write writes data on console -func (w *Writer) Write(data []byte) (n int, err error) { - w.mutex.Lock() - defer w.mutex.Unlock() - var csbi consoleScreenBufferInfo - procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) - - handle := w.handle - - var er *bytes.Reader - if w.rest.Len() > 0 { - var rest bytes.Buffer - w.rest.WriteTo(&rest) - w.rest.Reset() - rest.Write(data) - er = bytes.NewReader(rest.Bytes()) - } else { - er = bytes.NewReader(data) - } - var plaintext bytes.Buffer -loop: - for { - c1, err := er.ReadByte() - if err != nil { - plaintext.WriteTo(w.out) - break loop - } - if c1 != 0x1b { - plaintext.WriteByte(c1) - continue - } - _, err = plaintext.WriteTo(w.out) - if err != nil { - break loop - } - c2, err := er.ReadByte() - if err != nil { - break loop - } - - switch c2 { - case '>': - continue - case ']': - w.rest.WriteByte(c1) - w.rest.WriteByte(c2) - er.WriteTo(&w.rest) - if bytes.IndexByte(w.rest.Bytes(), 0x07) == -1 { - break loop - } - er = bytes.NewReader(w.rest.Bytes()[2:]) - err := doTitleSequence(er) - if err != nil { - break loop - } - w.rest.Reset() - continue - // https://github.com/mattn/go-colorable/issues/27 - case '7': - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - w.oldpos = csbi.cursorPosition - continue - case '8': - procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&w.oldpos))) - continue - case 0x5b: - // execute part after switch - default: - continue - } - - w.rest.WriteByte(c1) - w.rest.WriteByte(c2) - er.WriteTo(&w.rest) - - var buf bytes.Buffer - var m byte - for i, c := range w.rest.Bytes()[2:] { - if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { - m = c - er = bytes.NewReader(w.rest.Bytes()[2+i+1:]) - w.rest.Reset() - break - } - buf.Write([]byte(string(c))) - } - if m == 0 { - break loop - } - - switch m { - case 'A': - n, err = atoiWithDefault(buf.String(), 1) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.y -= short(n) - procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'B': - n, err = atoiWithDefault(buf.String(), 1) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.y += short(n) - procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'C': - n, err = atoiWithDefault(buf.String(), 1) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.x += short(n) - procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'D': - n, err = atoiWithDefault(buf.String(), 1) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.x -= short(n) - if csbi.cursorPosition.x < 0 { - csbi.cursorPosition.x = 0 - } - procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'E': - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.x = 0 - csbi.cursorPosition.y += short(n) - procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'F': - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.x = 0 - csbi.cursorPosition.y -= short(n) - procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'G': - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - if n < 1 { - n = 1 - } - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - csbi.cursorPosition.x = short(n - 1) - procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'H', 'f': - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - if buf.Len() > 0 { - token := strings.Split(buf.String(), ";") - switch len(token) { - case 1: - n1, err := strconv.Atoi(token[0]) - if err != nil { - continue - } - csbi.cursorPosition.y = short(n1 - 1) - case 2: - n1, err := strconv.Atoi(token[0]) - if err != nil { - continue - } - n2, err := strconv.Atoi(token[1]) - if err != nil { - continue - } - csbi.cursorPosition.x = short(n2 - 1) - csbi.cursorPosition.y = short(n1 - 1) - } - } else { - csbi.cursorPosition.y = 0 - } - procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) - case 'J': - n := 0 - if buf.Len() > 0 { - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - } - var count, written dword - var cursor coord - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - switch n { - case 0: - cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y} - count = dword(csbi.size.x) - dword(csbi.cursorPosition.x) + dword(csbi.size.y-csbi.cursorPosition.y)*dword(csbi.size.x) - case 1: - cursor = coord{x: csbi.window.left, y: csbi.window.top} - count = dword(csbi.size.x) - dword(csbi.cursorPosition.x) + dword(csbi.window.top-csbi.cursorPosition.y)*dword(csbi.size.x) - case 2: - cursor = coord{x: csbi.window.left, y: csbi.window.top} - count = dword(csbi.size.x) - dword(csbi.cursorPosition.x) + dword(csbi.size.y-csbi.cursorPosition.y)*dword(csbi.size.x) - } - procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) - procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) - case 'K': - n := 0 - if buf.Len() > 0 { - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - } - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - var cursor coord - var count, written dword - switch n { - case 0: - cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y} - count = dword(csbi.size.x - csbi.cursorPosition.x) - case 1: - cursor = coord{x: csbi.window.left, y: csbi.cursorPosition.y} - count = dword(csbi.size.x - csbi.cursorPosition.x) - case 2: - cursor = coord{x: csbi.window.left, y: csbi.cursorPosition.y} - count = dword(csbi.size.x) - } - procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) - procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) - case 'X': - n := 0 - if buf.Len() > 0 { - n, err = strconv.Atoi(buf.String()) - if err != nil { - continue - } - } - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - var cursor coord - var written dword - cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y} - procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(n), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) - procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(n), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) - case 'm': - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - attr := csbi.attributes - cs := buf.String() - if cs == "" { - procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(w.oldattr)) - continue - } - token := strings.Split(cs, ";") - for i := 0; i < len(token); i++ { - ns := token[i] - if n, err = strconv.Atoi(ns); err == nil { - switch { - case n == 0 || n == 100: - attr = w.oldattr - case n == 4: - attr |= commonLvbUnderscore - case (1 <= n && n <= 3) || n == 5: - attr |= foregroundIntensity - case n == 7 || n == 27: - attr = - (attr &^ (foregroundMask | backgroundMask)) | - ((attr & foregroundMask) << 4) | - ((attr & backgroundMask) >> 4) - case n == 22: - attr &^= foregroundIntensity - case n == 24: - attr &^= commonLvbUnderscore - case 30 <= n && n <= 37: - attr &= backgroundMask - if (n-30)&1 != 0 { - attr |= foregroundRed - } - if (n-30)&2 != 0 { - attr |= foregroundGreen - } - if (n-30)&4 != 0 { - attr |= foregroundBlue - } - case n == 38: // set foreground color. - if i < len(token)-2 && (token[i+1] == "5" || token[i+1] == "05") { - if n256, err := strconv.Atoi(token[i+2]); err == nil { - if n256foreAttr == nil { - n256setup() - } - attr &= backgroundMask - attr |= n256foreAttr[n256%len(n256foreAttr)] - i += 2 - } - } else if len(token) == 5 && token[i+1] == "2" { - var r, g, b int - r, _ = strconv.Atoi(token[i+2]) - g, _ = strconv.Atoi(token[i+3]) - b, _ = strconv.Atoi(token[i+4]) - i += 4 - if r > 127 { - attr |= foregroundRed - } - if g > 127 { - attr |= foregroundGreen - } - if b > 127 { - attr |= foregroundBlue - } - } else { - attr = attr & (w.oldattr & backgroundMask) - } - case n == 39: // reset foreground color. - attr &= backgroundMask - attr |= w.oldattr & foregroundMask - case 40 <= n && n <= 47: - attr &= foregroundMask - if (n-40)&1 != 0 { - attr |= backgroundRed - } - if (n-40)&2 != 0 { - attr |= backgroundGreen - } - if (n-40)&4 != 0 { - attr |= backgroundBlue - } - case n == 48: // set background color. - if i < len(token)-2 && token[i+1] == "5" { - if n256, err := strconv.Atoi(token[i+2]); err == nil { - if n256backAttr == nil { - n256setup() - } - attr &= foregroundMask - attr |= n256backAttr[n256%len(n256backAttr)] - i += 2 - } - } else if len(token) == 5 && token[i+1] == "2" { - var r, g, b int - r, _ = strconv.Atoi(token[i+2]) - g, _ = strconv.Atoi(token[i+3]) - b, _ = strconv.Atoi(token[i+4]) - i += 4 - if r > 127 { - attr |= backgroundRed - } - if g > 127 { - attr |= backgroundGreen - } - if b > 127 { - attr |= backgroundBlue - } - } else { - attr = attr & (w.oldattr & foregroundMask) - } - case n == 49: // reset foreground color. - attr &= foregroundMask - attr |= w.oldattr & backgroundMask - case 90 <= n && n <= 97: - attr = (attr & backgroundMask) - attr |= foregroundIntensity - if (n-90)&1 != 0 { - attr |= foregroundRed - } - if (n-90)&2 != 0 { - attr |= foregroundGreen - } - if (n-90)&4 != 0 { - attr |= foregroundBlue - } - case 100 <= n && n <= 107: - attr = (attr & foregroundMask) - attr |= backgroundIntensity - if (n-100)&1 != 0 { - attr |= backgroundRed - } - if (n-100)&2 != 0 { - attr |= backgroundGreen - } - if (n-100)&4 != 0 { - attr |= backgroundBlue - } - } - procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(attr)) - } - } - case 'h': - var ci consoleCursorInfo - cs := buf.String() - if cs == "5>" { - procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci))) - ci.visible = 0 - procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci))) - } else if cs == "?25" { - procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci))) - ci.visible = 1 - procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci))) - } else if cs == "?1049" { - if w.althandle == 0 { - h, _, _ := procCreateConsoleScreenBuffer.Call(uintptr(genericRead|genericWrite), 0, 0, uintptr(consoleTextmodeBuffer), 0, 0) - w.althandle = syscall.Handle(h) - if w.althandle != 0 { - handle = w.althandle - } - } - } - case 'l': - var ci consoleCursorInfo - cs := buf.String() - if cs == "5>" { - procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci))) - ci.visible = 1 - procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci))) - } else if cs == "?25" { - procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci))) - ci.visible = 0 - procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci))) - } else if cs == "?1049" { - if w.althandle != 0 { - syscall.CloseHandle(w.althandle) - w.althandle = 0 - handle = w.handle - } - } - case 's': - procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) - w.oldpos = csbi.cursorPosition - case 'u': - procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&w.oldpos))) - } - } - - return len(data), nil -} - -type consoleColor struct { - rgb int - red bool - green bool - blue bool - intensity bool -} - -func (c consoleColor) foregroundAttr() (attr word) { - if c.red { - attr |= foregroundRed - } - if c.green { - attr |= foregroundGreen - } - if c.blue { - attr |= foregroundBlue - } - if c.intensity { - attr |= foregroundIntensity - } - return -} - -func (c consoleColor) backgroundAttr() (attr word) { - if c.red { - attr |= backgroundRed - } - if c.green { - attr |= backgroundGreen - } - if c.blue { - attr |= backgroundBlue - } - if c.intensity { - attr |= backgroundIntensity - } - return -} - -var color16 = []consoleColor{ - {0x000000, false, false, false, false}, - {0x000080, false, false, true, false}, - {0x008000, false, true, false, false}, - {0x008080, false, true, true, false}, - {0x800000, true, false, false, false}, - {0x800080, true, false, true, false}, - {0x808000, true, true, false, false}, - {0xc0c0c0, true, true, true, false}, - {0x808080, false, false, false, true}, - {0x0000ff, false, false, true, true}, - {0x00ff00, false, true, false, true}, - {0x00ffff, false, true, true, true}, - {0xff0000, true, false, false, true}, - {0xff00ff, true, false, true, true}, - {0xffff00, true, true, false, true}, - {0xffffff, true, true, true, true}, -} - -type hsv struct { - h, s, v float32 -} - -func (a hsv) dist(b hsv) float32 { - dh := a.h - b.h - switch { - case dh > 0.5: - dh = 1 - dh - case dh < -0.5: - dh = -1 - dh - } - ds := a.s - b.s - dv := a.v - b.v - return float32(math.Sqrt(float64(dh*dh + ds*ds + dv*dv))) -} - -func toHSV(rgb int) hsv { - r, g, b := float32((rgb&0xFF0000)>>16)/256.0, - float32((rgb&0x00FF00)>>8)/256.0, - float32(rgb&0x0000FF)/256.0 - min, max := minmax3f(r, g, b) - h := max - min - if h > 0 { - if max == r { - h = (g - b) / h - if h < 0 { - h += 6 - } - } else if max == g { - h = 2 + (b-r)/h - } else { - h = 4 + (r-g)/h - } - } - h /= 6.0 - s := max - min - if max != 0 { - s /= max - } - v := max - return hsv{h: h, s: s, v: v} -} - -type hsvTable []hsv - -func toHSVTable(rgbTable []consoleColor) hsvTable { - t := make(hsvTable, len(rgbTable)) - for i, c := range rgbTable { - t[i] = toHSV(c.rgb) - } - return t -} - -func (t hsvTable) find(rgb int) consoleColor { - hsv := toHSV(rgb) - n := 7 - l := float32(5.0) - for i, p := range t { - d := hsv.dist(p) - if d < l { - l, n = d, i - } - } - return color16[n] -} - -func minmax3f(a, b, c float32) (min, max float32) { - if a < b { - if b < c { - return a, c - } else if a < c { - return a, b - } else { - return c, b - } - } else { - if a < c { - return b, c - } else if b < c { - return b, a - } else { - return c, a - } - } -} - -var n256foreAttr []word -var n256backAttr []word - -func n256setup() { - n256foreAttr = make([]word, 256) - n256backAttr = make([]word, 256) - t := toHSVTable(color16) - for i, rgb := range color256 { - c := t.find(rgb) - n256foreAttr[i] = c.foregroundAttr() - n256backAttr[i] = c.backgroundAttr() - } -} - -// EnableColorsStdout enable colors if possible. -func EnableColorsStdout(enabled *bool) func() { - var mode uint32 - h := os.Stdout.Fd() - if r, _, _ := procGetConsoleMode.Call(h, uintptr(unsafe.Pointer(&mode))); r != 0 { - if r, _, _ = procSetConsoleMode.Call(h, uintptr(mode|cENABLE_VIRTUAL_TERMINAL_PROCESSING)); r != 0 { - if enabled != nil { - *enabled = true - } - return func() { - procSetConsoleMode.Call(h, uintptr(mode)) - } - } - } - if enabled != nil { - *enabled = true - } - return func() {} -} diff --git a/vendor/github.com/mattn/go-colorable/go.test.sh b/vendor/github.com/mattn/go-colorable/go.test.sh deleted file mode 100644 index 012162b0..00000000 --- a/vendor/github.com/mattn/go-colorable/go.test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -echo "" > coverage.txt - -for d in $(go list ./... | grep -v vendor); do - go test -race -coverprofile=profile.out -covermode=atomic "$d" - if [ -f profile.out ]; then - cat profile.out >> coverage.txt - rm profile.out - fi -done diff --git a/vendor/github.com/mattn/go-colorable/noncolorable.go b/vendor/github.com/mattn/go-colorable/noncolorable.go deleted file mode 100644 index 05d6f74b..00000000 --- a/vendor/github.com/mattn/go-colorable/noncolorable.go +++ /dev/null @@ -1,57 +0,0 @@ -package colorable - -import ( - "bytes" - "io" -) - -// NonColorable holds writer but removes escape sequence. -type NonColorable struct { - out io.Writer -} - -// NewNonColorable returns new instance of Writer which removes escape sequence from Writer. -func NewNonColorable(w io.Writer) io.Writer { - return &NonColorable{out: w} -} - -// Write writes data on console -func (w *NonColorable) Write(data []byte) (n int, err error) { - er := bytes.NewReader(data) - var plaintext bytes.Buffer -loop: - for { - c1, err := er.ReadByte() - if err != nil { - plaintext.WriteTo(w.out) - break loop - } - if c1 != 0x1b { - plaintext.WriteByte(c1) - continue - } - _, err = plaintext.WriteTo(w.out) - if err != nil { - break loop - } - c2, err := er.ReadByte() - if err != nil { - break loop - } - if c2 != 0x5b { - continue - } - - for { - c, err := er.ReadByte() - if err != nil { - break loop - } - if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { - break - } - } - } - - return len(data), nil -} diff --git a/vendor/github.com/mattn/go-isatty/LICENSE b/vendor/github.com/mattn/go-isatty/LICENSE deleted file mode 100644 index 65dc692b..00000000 --- a/vendor/github.com/mattn/go-isatty/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -Copyright (c) Yasuhiro MATSUMOTO - -MIT License (Expat) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/mattn/go-isatty/README.md b/vendor/github.com/mattn/go-isatty/README.md deleted file mode 100644 index 38418353..00000000 --- a/vendor/github.com/mattn/go-isatty/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# go-isatty - -[![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty) -[![Codecov](https://codecov.io/gh/mattn/go-isatty/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-isatty) -[![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master) -[![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty) - -isatty for golang - -## Usage - -```go -package main - -import ( - "fmt" - "github.com/mattn/go-isatty" - "os" -) - -func main() { - if isatty.IsTerminal(os.Stdout.Fd()) { - fmt.Println("Is Terminal") - } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) { - fmt.Println("Is Cygwin/MSYS2 Terminal") - } else { - fmt.Println("Is Not Terminal") - } -} -``` - -## Installation - -``` -$ go get github.com/mattn/go-isatty -``` - -## License - -MIT - -## Author - -Yasuhiro Matsumoto (a.k.a mattn) - -## Thanks - -* k-takata: base idea for IsCygwinTerminal - - https://github.com/k-takata/go-iscygpty diff --git a/vendor/github.com/mattn/go-isatty/doc.go b/vendor/github.com/mattn/go-isatty/doc.go deleted file mode 100644 index 17d4f90e..00000000 --- a/vendor/github.com/mattn/go-isatty/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package isatty implements interface to isatty -package isatty diff --git a/vendor/github.com/mattn/go-isatty/go.test.sh b/vendor/github.com/mattn/go-isatty/go.test.sh deleted file mode 100644 index 012162b0..00000000 --- a/vendor/github.com/mattn/go-isatty/go.test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -echo "" > coverage.txt - -for d in $(go list ./... | grep -v vendor); do - go test -race -coverprofile=profile.out -covermode=atomic "$d" - if [ -f profile.out ]; then - cat profile.out >> coverage.txt - rm profile.out - fi -done diff --git a/vendor/github.com/mattn/go-isatty/isatty_bsd.go b/vendor/github.com/mattn/go-isatty/isatty_bsd.go deleted file mode 100644 index 39bbcf00..00000000 --- a/vendor/github.com/mattn/go-isatty/isatty_bsd.go +++ /dev/null @@ -1,19 +0,0 @@ -//go:build (darwin || freebsd || openbsd || netbsd || dragonfly) && !appengine -// +build darwin freebsd openbsd netbsd dragonfly -// +build !appengine - -package isatty - -import "golang.org/x/sys/unix" - -// IsTerminal return true if the file descriptor is terminal. -func IsTerminal(fd uintptr) bool { - _, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA) - return err == nil -} - -// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 -// terminal. This is also always false on this environment. -func IsCygwinTerminal(fd uintptr) bool { - return false -} diff --git a/vendor/github.com/mattn/go-isatty/isatty_others.go b/vendor/github.com/mattn/go-isatty/isatty_others.go deleted file mode 100644 index 31503226..00000000 --- a/vendor/github.com/mattn/go-isatty/isatty_others.go +++ /dev/null @@ -1,16 +0,0 @@ -//go:build appengine || js || nacl || wasm -// +build appengine js nacl wasm - -package isatty - -// IsTerminal returns true if the file descriptor is terminal which -// is always false on js and appengine classic which is a sandboxed PaaS. -func IsTerminal(fd uintptr) bool { - return false -} - -// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 -// terminal. This is also always false on this environment. -func IsCygwinTerminal(fd uintptr) bool { - return false -} diff --git a/vendor/github.com/mattn/go-isatty/isatty_plan9.go b/vendor/github.com/mattn/go-isatty/isatty_plan9.go deleted file mode 100644 index bae7f9bb..00000000 --- a/vendor/github.com/mattn/go-isatty/isatty_plan9.go +++ /dev/null @@ -1,23 +0,0 @@ -//go:build plan9 -// +build plan9 - -package isatty - -import ( - "syscall" -) - -// IsTerminal returns true if the given file descriptor is a terminal. -func IsTerminal(fd uintptr) bool { - path, err := syscall.Fd2path(int(fd)) - if err != nil { - return false - } - return path == "/dev/cons" || path == "/mnt/term/dev/cons" -} - -// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 -// terminal. This is also always false on this environment. -func IsCygwinTerminal(fd uintptr) bool { - return false -} diff --git a/vendor/github.com/mattn/go-isatty/isatty_solaris.go b/vendor/github.com/mattn/go-isatty/isatty_solaris.go deleted file mode 100644 index 0c3acf2d..00000000 --- a/vendor/github.com/mattn/go-isatty/isatty_solaris.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build solaris && !appengine -// +build solaris,!appengine - -package isatty - -import ( - "golang.org/x/sys/unix" -) - -// IsTerminal returns true if the given file descriptor is a terminal. -// see: https://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/isatty.c -func IsTerminal(fd uintptr) bool { - _, err := unix.IoctlGetTermio(int(fd), unix.TCGETA) - return err == nil -} - -// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 -// terminal. This is also always false on this environment. -func IsCygwinTerminal(fd uintptr) bool { - return false -} diff --git a/vendor/github.com/mattn/go-isatty/isatty_tcgets.go b/vendor/github.com/mattn/go-isatty/isatty_tcgets.go deleted file mode 100644 index 67787657..00000000 --- a/vendor/github.com/mattn/go-isatty/isatty_tcgets.go +++ /dev/null @@ -1,19 +0,0 @@ -//go:build (linux || aix || zos) && !appengine -// +build linux aix zos -// +build !appengine - -package isatty - -import "golang.org/x/sys/unix" - -// IsTerminal return true if the file descriptor is terminal. -func IsTerminal(fd uintptr) bool { - _, err := unix.IoctlGetTermios(int(fd), unix.TCGETS) - return err == nil -} - -// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 -// terminal. This is also always false on this environment. -func IsCygwinTerminal(fd uintptr) bool { - return false -} diff --git a/vendor/github.com/mattn/go-isatty/isatty_windows.go b/vendor/github.com/mattn/go-isatty/isatty_windows.go deleted file mode 100644 index 8e3c9917..00000000 --- a/vendor/github.com/mattn/go-isatty/isatty_windows.go +++ /dev/null @@ -1,125 +0,0 @@ -//go:build windows && !appengine -// +build windows,!appengine - -package isatty - -import ( - "errors" - "strings" - "syscall" - "unicode/utf16" - "unsafe" -) - -const ( - objectNameInfo uintptr = 1 - fileNameInfo = 2 - fileTypePipe = 3 -) - -var ( - kernel32 = syscall.NewLazyDLL("kernel32.dll") - ntdll = syscall.NewLazyDLL("ntdll.dll") - procGetConsoleMode = kernel32.NewProc("GetConsoleMode") - procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx") - procGetFileType = kernel32.NewProc("GetFileType") - procNtQueryObject = ntdll.NewProc("NtQueryObject") -) - -func init() { - // Check if GetFileInformationByHandleEx is available. - if procGetFileInformationByHandleEx.Find() != nil { - procGetFileInformationByHandleEx = nil - } -} - -// IsTerminal return true if the file descriptor is terminal. -func IsTerminal(fd uintptr) bool { - var st uint32 - r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) - return r != 0 && e == 0 -} - -// Check pipe name is used for cygwin/msys2 pty. -// Cygwin/MSYS2 PTY has a name like: -// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master -func isCygwinPipeName(name string) bool { - token := strings.Split(name, "-") - if len(token) < 5 { - return false - } - - if token[0] != `\msys` && - token[0] != `\cygwin` && - token[0] != `\Device\NamedPipe\msys` && - token[0] != `\Device\NamedPipe\cygwin` { - return false - } - - if token[1] == "" { - return false - } - - if !strings.HasPrefix(token[2], "pty") { - return false - } - - if token[3] != `from` && token[3] != `to` { - return false - } - - if token[4] != "master" { - return false - } - - return true -} - -// getFileNameByHandle use the undocomented ntdll NtQueryObject to get file full name from file handler -// since GetFileInformationByHandleEx is not available under windows Vista and still some old fashion -// guys are using Windows XP, this is a workaround for those guys, it will also work on system from -// Windows vista to 10 -// see https://stackoverflow.com/a/18792477 for details -func getFileNameByHandle(fd uintptr) (string, error) { - if procNtQueryObject == nil { - return "", errors.New("ntdll.dll: NtQueryObject not supported") - } - - var buf [4 + syscall.MAX_PATH]uint16 - var result int - r, _, e := syscall.Syscall6(procNtQueryObject.Addr(), 5, - fd, objectNameInfo, uintptr(unsafe.Pointer(&buf)), uintptr(2*len(buf)), uintptr(unsafe.Pointer(&result)), 0) - if r != 0 { - return "", e - } - return string(utf16.Decode(buf[4 : 4+buf[0]/2])), nil -} - -// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 -// terminal. -func IsCygwinTerminal(fd uintptr) bool { - if procGetFileInformationByHandleEx == nil { - name, err := getFileNameByHandle(fd) - if err != nil { - return false - } - return isCygwinPipeName(name) - } - - // Cygwin/msys's pty is a pipe. - ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0) - if ft != fileTypePipe || e != 0 { - return false - } - - var buf [2 + syscall.MAX_PATH]uint16 - r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), - 4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)), - uintptr(len(buf)*2), 0, 0) - if r == 0 || e != 0 { - return false - } - - l := *(*uint32)(unsafe.Pointer(&buf)) - return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2]))) -} diff --git a/vendor/github.com/rs/zerolog/.gitignore b/vendor/github.com/rs/zerolog/.gitignore deleted file mode 100644 index 8ebe58b1..00000000 --- a/vendor/github.com/rs/zerolog/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test -tmp - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/rs/zerolog/CNAME b/vendor/github.com/rs/zerolog/CNAME deleted file mode 100644 index 9ce57a6e..00000000 --- a/vendor/github.com/rs/zerolog/CNAME +++ /dev/null @@ -1 +0,0 @@ -zerolog.io \ No newline at end of file diff --git a/vendor/github.com/rs/zerolog/LICENSE b/vendor/github.com/rs/zerolog/LICENSE deleted file mode 100644 index 677e07f7..00000000 --- a/vendor/github.com/rs/zerolog/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Olivier Poitrey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/rs/zerolog/README.md b/vendor/github.com/rs/zerolog/README.md deleted file mode 100644 index 95666b32..00000000 --- a/vendor/github.com/rs/zerolog/README.md +++ /dev/null @@ -1,716 +0,0 @@ -# Zero Allocation JSON Logger - -[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/rs/zerolog) [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/rs/zerolog/master/LICENSE) [![Build Status](https://travis-ci.org/rs/zerolog.svg?branch=master)](https://travis-ci.org/rs/zerolog) [![Coverage](http://gocover.io/_badge/github.com/rs/zerolog)](http://gocover.io/github.com/rs/zerolog) - -The zerolog package provides a fast and simple logger dedicated to JSON output. - -Zerolog's API is designed to provide both a great developer experience and stunning [performance](#benchmarks). Its unique chaining API allows zerolog to write JSON (or CBOR) log events by avoiding allocations and reflection. - -Uber's [zap](https://godoc.org/go.uber.org/zap) library pioneered this approach. Zerolog is taking this concept to the next level with a simpler to use API and even better performance. - -To keep the code base and the API simple, zerolog focuses on efficient structured logging only. Pretty logging on the console is made possible using the provided (but inefficient) [`zerolog.ConsoleWriter`](#pretty-logging). - -![Pretty Logging Image](pretty.png) - -## Who uses zerolog - -Find out [who uses zerolog](https://github.com/rs/zerolog/wiki/Who-uses-zerolog) and add your company / project to the list. - -## Features - -* [Blazing fast](#benchmarks) -* [Low to zero allocation](#benchmarks) -* [Leveled logging](#leveled-logging) -* [Sampling](#log-sampling) -* [Hooks](#hooks) -* [Contextual fields](#contextual-logging) -* `context.Context` integration -* [Integration with `net/http`](#integration-with-nethttp) -* [JSON and CBOR encoding formats](#binary-encoding) -* [Pretty logging for development](#pretty-logging) -* [Error Logging (with optional Stacktrace)](#error-logging) - -## Installation - -```bash -go get -u github.com/rs/zerolog/log -``` - -## Getting Started - -### Simple Logging Example - -For simple logging, import the global logger package **github.com/rs/zerolog/log** - -```go -package main - -import ( - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -func main() { - // UNIX Time is faster and smaller than most timestamps - zerolog.TimeFieldFormat = zerolog.TimeFormatUnix - - log.Print("hello world") -} - -// Output: {"time":1516134303,"level":"debug","message":"hello world"} -``` -> Note: By default log writes to `os.Stderr` -> Note: The default log level for `log.Print` is *debug* - -### Contextual Logging - -**zerolog** allows data to be added to log messages in the form of key:value pairs. The data added to the message adds "context" about the log event that can be critical for debugging as well as myriad other purposes. An example of this is below: - -```go -package main - -import ( - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -func main() { - zerolog.TimeFieldFormat = zerolog.TimeFormatUnix - - log.Debug(). - Str("Scale", "833 cents"). - Float64("Interval", 833.09). - Msg("Fibonacci is everywhere") - - log.Debug(). - Str("Name", "Tom"). - Send() -} - -// Output: {"level":"debug","Scale":"833 cents","Interval":833.09,"time":1562212768,"message":"Fibonacci is everywhere"} -// Output: {"level":"debug","Name":"Tom","time":1562212768} -``` - -> You'll note in the above example that when adding contextual fields, the fields are strongly typed. You can find the full list of supported fields [here](#standard-types) - -### Leveled Logging - -#### Simple Leveled Logging Example - -```go -package main - -import ( - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -func main() { - zerolog.TimeFieldFormat = zerolog.TimeFormatUnix - - log.Info().Msg("hello world") -} - -// Output: {"time":1516134303,"level":"info","message":"hello world"} -``` - -> It is very important to note that when using the **zerolog** chaining API, as shown above (`log.Info().Msg("hello world"`), the chain must have either the `Msg` or `Msgf` method call. If you forget to add either of these, the log will not occur and there is no compile time error to alert you of this. - -**zerolog** allows for logging at the following levels (from highest to lowest): - -* panic (`zerolog.PanicLevel`, 5) -* fatal (`zerolog.FatalLevel`, 4) -* error (`zerolog.ErrorLevel`, 3) -* warn (`zerolog.WarnLevel`, 2) -* info (`zerolog.InfoLevel`, 1) -* debug (`zerolog.DebugLevel`, 0) -* trace (`zerolog.TraceLevel`, -1) - -You can set the Global logging level to any of these options using the `SetGlobalLevel` function in the zerolog package, passing in one of the given constants above, e.g. `zerolog.InfoLevel` would be the "info" level. Whichever level is chosen, all logs with a level greater than or equal to that level will be written. To turn off logging entirely, pass the `zerolog.Disabled` constant. - -#### Setting Global Log Level - -This example uses command-line flags to demonstrate various outputs depending on the chosen log level. - -```go -package main - -import ( - "flag" - - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -func main() { - zerolog.TimeFieldFormat = zerolog.TimeFormatUnix - debug := flag.Bool("debug", false, "sets log level to debug") - - flag.Parse() - - // Default level for this example is info, unless debug flag is present - zerolog.SetGlobalLevel(zerolog.InfoLevel) - if *debug { - zerolog.SetGlobalLevel(zerolog.DebugLevel) - } - - log.Debug().Msg("This message appears only when log level set to Debug") - log.Info().Msg("This message appears when log level set to Debug or Info") - - if e := log.Debug(); e.Enabled() { - // Compute log output only if enabled. - value := "bar" - e.Str("foo", value).Msg("some debug message") - } -} -``` - -Info Output (no flag) - -```bash -$ ./logLevelExample -{"time":1516387492,"level":"info","message":"This message appears when log level set to Debug or Info"} -``` - -Debug Output (debug flag set) - -```bash -$ ./logLevelExample -debug -{"time":1516387573,"level":"debug","message":"This message appears only when log level set to Debug"} -{"time":1516387573,"level":"info","message":"This message appears when log level set to Debug or Info"} -{"time":1516387573,"level":"debug","foo":"bar","message":"some debug message"} -``` - -#### Logging without Level or Message - -You may choose to log without a specific level by using the `Log` method. You may also write without a message by setting an empty string in the `msg string` parameter of the `Msg` method. Both are demonstrated in the example below. - -```go -package main - -import ( - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -func main() { - zerolog.TimeFieldFormat = zerolog.TimeFormatUnix - - log.Log(). - Str("foo", "bar"). - Msg("") -} - -// Output: {"time":1494567715,"foo":"bar"} -``` - -### Error Logging - -You can log errors using the `Err` method - -```go -package main - -import ( - "errors" - - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -func main() { - zerolog.TimeFieldFormat = zerolog.TimeFormatUnix - - err := errors.New("seems we have an error here") - log.Error().Err(err).Msg("") -} - -// Output: {"level":"error","error":"seems we have an error here","time":1609085256} -``` - -> The default field name for errors is `error`, you can change this by setting `zerolog.ErrorFieldName` to meet your needs. - -#### Error Logging with Stacktrace - -Using `github.com/pkg/errors`, you can add a formatted stacktrace to your errors. - -```go -package main - -import ( - "github.com/pkg/errors" - "github.com/rs/zerolog/pkgerrors" - - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -func main() { - zerolog.TimeFieldFormat = zerolog.TimeFormatUnix - zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack - - err := outer() - log.Error().Stack().Err(err).Msg("") -} - -func inner() error { - return errors.New("seems we have an error here") -} - -func middle() error { - err := inner() - if err != nil { - return err - } - return nil -} - -func outer() error { - err := middle() - if err != nil { - return err - } - return nil -} - -// Output: {"level":"error","stack":[{"func":"inner","line":"20","source":"errors.go"},{"func":"middle","line":"24","source":"errors.go"},{"func":"outer","line":"32","source":"errors.go"},{"func":"main","line":"15","source":"errors.go"},{"func":"main","line":"204","source":"proc.go"},{"func":"goexit","line":"1374","source":"asm_amd64.s"}],"error":"seems we have an error here","time":1609086683} -``` - -> zerolog.ErrorStackMarshaler must be set in order for the stack to output anything. - -#### Logging Fatal Messages - -```go -package main - -import ( - "errors" - - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -func main() { - err := errors.New("A repo man spends his life getting into tense situations") - service := "myservice" - - zerolog.TimeFieldFormat = zerolog.TimeFormatUnix - - log.Fatal(). - Err(err). - Str("service", service). - Msgf("Cannot start %s", service) -} - -// Output: {"time":1516133263,"level":"fatal","error":"A repo man spends his life getting into tense situations","service":"myservice","message":"Cannot start myservice"} -// exit status 1 -``` - -> NOTE: Using `Msgf` generates one allocation even when the logger is disabled. - - -### Create logger instance to manage different outputs - -```go -logger := zerolog.New(os.Stderr).With().Timestamp().Logger() - -logger.Info().Str("foo", "bar").Msg("hello world") - -// Output: {"level":"info","time":1494567715,"message":"hello world","foo":"bar"} -``` - -### Sub-loggers let you chain loggers with additional context - -```go -sublogger := log.With(). - Str("component", "foo"). - Logger() -sublogger.Info().Msg("hello world") - -// Output: {"level":"info","time":1494567715,"message":"hello world","component":"foo"} -``` - -### Pretty logging - -To log a human-friendly, colorized output, use `zerolog.ConsoleWriter`: - -```go -log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) - -log.Info().Str("foo", "bar").Msg("Hello world") - -// Output: 3:04PM INF Hello World foo=bar -``` - -To customize the configuration and formatting: - -```go -output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339} -output.FormatLevel = func(i interface{}) string { - return strings.ToUpper(fmt.Sprintf("| %-6s|", i)) -} -output.FormatMessage = func(i interface{}) string { - return fmt.Sprintf("***%s****", i) -} -output.FormatFieldName = func(i interface{}) string { - return fmt.Sprintf("%s:", i) -} -output.FormatFieldValue = func(i interface{}) string { - return strings.ToUpper(fmt.Sprintf("%s", i)) -} - -log := zerolog.New(output).With().Timestamp().Logger() - -log.Info().Str("foo", "bar").Msg("Hello World") - -// Output: 2006-01-02T15:04:05Z07:00 | INFO | ***Hello World**** foo:BAR -``` - -### Sub dictionary - -```go -log.Info(). - Str("foo", "bar"). - Dict("dict", zerolog.Dict(). - Str("bar", "baz"). - Int("n", 1), - ).Msg("hello world") - -// Output: {"level":"info","time":1494567715,"foo":"bar","dict":{"bar":"baz","n":1},"message":"hello world"} -``` - -### Customize automatic field names - -```go -zerolog.TimestampFieldName = "t" -zerolog.LevelFieldName = "l" -zerolog.MessageFieldName = "m" - -log.Info().Msg("hello world") - -// Output: {"l":"info","t":1494567715,"m":"hello world"} -``` - -### Add contextual fields to the global logger - -```go -log.Logger = log.With().Str("foo", "bar").Logger() -``` - -### Add file and line number to log - -Equivalent of `Llongfile`: - -```go -log.Logger = log.With().Caller().Logger() -log.Info().Msg("hello world") - -// Output: {"level": "info", "message": "hello world", "caller": "/go/src/your_project/some_file:21"} -``` - -Equivalent of `Lshortfile`: - -```go -zerolog.CallerMarshalFunc = func(file string, line int) string { - short := file - for i := len(file) - 1; i > 0; i-- { - if file[i] == '/' { - short = file[i+1:] - break - } - } - file = short - return file + ":" + strconv.Itoa(line) -} -log.Logger = log.With().Caller().Logger() -log.Info().Msg("hello world") - -// Output: {"level": "info", "message": "hello world", "caller": "some_file:21"} -``` - -### Thread-safe, lock-free, non-blocking writer - -If your writer might be slow or not thread-safe and you need your log producers to never get slowed down by a slow writer, you can use a `diode.Writer` as follows: - -```go -wr := diode.NewWriter(os.Stdout, 1000, 10*time.Millisecond, func(missed int) { - fmt.Printf("Logger Dropped %d messages", missed) - }) -log := zerolog.New(wr) -log.Print("test") -``` - -You will need to install `code.cloudfoundry.org/go-diodes` to use this feature. - -### Log Sampling - -```go -sampled := log.Sample(&zerolog.BasicSampler{N: 10}) -sampled.Info().Msg("will be logged every 10 messages") - -// Output: {"time":1494567715,"level":"info","message":"will be logged every 10 messages"} -``` - -More advanced sampling: - -```go -// Will let 5 debug messages per period of 1 second. -// Over 5 debug message, 1 every 100 debug messages are logged. -// Other levels are not sampled. -sampled := log.Sample(zerolog.LevelSampler{ - DebugSampler: &zerolog.BurstSampler{ - Burst: 5, - Period: 1*time.Second, - NextSampler: &zerolog.BasicSampler{N: 100}, - }, -}) -sampled.Debug().Msg("hello world") - -// Output: {"time":1494567715,"level":"debug","message":"hello world"} -``` - -### Hooks - -```go -type SeverityHook struct{} - -func (h SeverityHook) Run(e *zerolog.Event, level zerolog.Level, msg string) { - if level != zerolog.NoLevel { - e.Str("severity", level.String()) - } -} - -hooked := log.Hook(SeverityHook{}) -hooked.Warn().Msg("") - -// Output: {"level":"warn","severity":"warn"} -``` - -### Pass a sub-logger by context - -```go -ctx := log.With().Str("component", "module").Logger().WithContext(ctx) - -log.Ctx(ctx).Info().Msg("hello world") - -// Output: {"component":"module","level":"info","message":"hello world"} -``` - -### Set as standard logger output - -```go -log := zerolog.New(os.Stdout).With(). - Str("foo", "bar"). - Logger() - -stdlog.SetFlags(0) -stdlog.SetOutput(log) - -stdlog.Print("hello world") - -// Output: {"foo":"bar","message":"hello world"} -``` - -### Integration with `net/http` - -The `github.com/rs/zerolog/hlog` package provides some helpers to integrate zerolog with `http.Handler`. - -In this example we use [alice](https://github.com/justinas/alice) to install logger for better readability. - -```go -log := zerolog.New(os.Stdout).With(). - Timestamp(). - Str("role", "my-service"). - Str("host", host). - Logger() - -c := alice.New() - -// Install the logger handler with default output on the console -c = c.Append(hlog.NewHandler(log)) - -// Install some provided extra handler to set some request's context fields. -// Thanks to that handler, all our logs will come with some prepopulated fields. -c = c.Append(hlog.AccessHandler(func(r *http.Request, status, size int, duration time.Duration) { - hlog.FromRequest(r).Info(). - Str("method", r.Method). - Stringer("url", r.URL). - Int("status", status). - Int("size", size). - Dur("duration", duration). - Msg("") -})) -c = c.Append(hlog.RemoteAddrHandler("ip")) -c = c.Append(hlog.UserAgentHandler("user_agent")) -c = c.Append(hlog.RefererHandler("referer")) -c = c.Append(hlog.RequestIDHandler("req_id", "Request-Id")) - -// Here is your final handler -h := c.Then(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - // Get the logger from the request's context. You can safely assume it - // will be always there: if the handler is removed, hlog.FromRequest - // will return a no-op logger. - hlog.FromRequest(r).Info(). - Str("user", "current user"). - Str("status", "ok"). - Msg("Something happened") - - // Output: {"level":"info","time":"2001-02-03T04:05:06Z","role":"my-service","host":"local-hostname","req_id":"b4g0l5t6tfid6dtrapu0","user":"current user","status":"ok","message":"Something happened"} -})) -http.Handle("/", h) - -if err := http.ListenAndServe(":8080", nil); err != nil { - log.Fatal().Err(err).Msg("Startup failed") -} -``` - -## Multiple Log Output -`zerolog.MultiLevelWriter` may be used to send the log message to multiple outputs. -In this example, we send the log message to both `os.Stdout` and the in-built ConsoleWriter. -```go -func main() { - consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout} - - multi := zerolog.MultiLevelWriter(consoleWriter, os.Stdout) - - logger := zerolog.New(multi).With().Timestamp().Logger() - - logger.Info().Msg("Hello World!") -} - -// Output (Line 1: Console; Line 2: Stdout) -// 12:36PM INF Hello World! -// {"level":"info","time":"2019-11-07T12:36:38+03:00","message":"Hello World!"} -``` - -## Global Settings - -Some settings can be changed and will be applied to all loggers: - -* `log.Logger`: You can set this value to customize the global logger (the one used by package level methods). -* `zerolog.SetGlobalLevel`: Can raise the minimum level of all loggers. Call this with `zerolog.Disabled` to disable logging altogether (quiet mode). -* `zerolog.DisableSampling`: If argument is `true`, all sampled loggers will stop sampling and issue 100% of their log events. -* `zerolog.TimestampFieldName`: Can be set to customize `Timestamp` field name. -* `zerolog.LevelFieldName`: Can be set to customize level field name. -* `zerolog.MessageFieldName`: Can be set to customize message field name. -* `zerolog.ErrorFieldName`: Can be set to customize `Err` field name. -* `zerolog.TimeFieldFormat`: Can be set to customize `Time` field value formatting. If set with `zerolog.TimeFormatUnix`, `zerolog.TimeFormatUnixMs` or `zerolog.TimeFormatUnixMicro`, times are formated as UNIX timestamp. -* `zerolog.DurationFieldUnit`: Can be set to customize the unit for time.Duration type fields added by `Dur` (default: `time.Millisecond`). -* `zerolog.DurationFieldInteger`: If set to `true`, `Dur` fields are formatted as integers instead of floats (default: `false`). -* `zerolog.ErrorHandler`: Called whenever zerolog fails to write an event on its output. If not set, an error is printed on the stderr. This handler must be thread safe and non-blocking. - -## Field Types - -### Standard Types - -* `Str` -* `Bool` -* `Int`, `Int8`, `Int16`, `Int32`, `Int64` -* `Uint`, `Uint8`, `Uint16`, `Uint32`, `Uint64` -* `Float32`, `Float64` - -### Advanced Fields - -* `Err`: Takes an `error` and renders it as a string using the `zerolog.ErrorFieldName` field name. -* `Func`: Run a `func` only if the level is enabled. -* `Timestamp`: Inserts a timestamp field with `zerolog.TimestampFieldName` field name, formatted using `zerolog.TimeFieldFormat`. -* `Time`: Adds a field with time formatted with `zerolog.TimeFieldFormat`. -* `Dur`: Adds a field with `time.Duration`. -* `Dict`: Adds a sub-key/value as a field of the event. -* `RawJSON`: Adds a field with an already encoded JSON (`[]byte`) -* `Hex`: Adds a field with value formatted as a hexadecimal string (`[]byte`) -* `Interface`: Uses reflection to marshal the type. - -Most fields are also available in the slice format (`Strs` for `[]string`, `Errs` for `[]error` etc.) - -## Binary Encoding - -In addition to the default JSON encoding, `zerolog` can produce binary logs using [CBOR](https://cbor.io) encoding. The choice of encoding can be decided at compile time using the build tag `binary_log` as follows: - -```bash -go build -tags binary_log . -``` - -To Decode binary encoded log files you can use any CBOR decoder. One has been tested to work -with zerolog library is [CSD](https://github.com/toravir/csd/). - -## Related Projects - -* [grpc-zerolog](https://github.com/cheapRoc/grpc-zerolog): Implementation of `grpclog.LoggerV2` interface using `zerolog` -* [overlog](https://github.com/Trendyol/overlog): Implementation of `Mapped Diagnostic Context` interface using `zerolog` -* [zerologr](https://github.com/go-logr/zerologr): Implementation of `logr.LogSink` interface using `zerolog` - -## Benchmarks - -See [logbench](http://hackemist.com/logbench/) for more comprehensive and up-to-date benchmarks. - -All operations are allocation free (those numbers *include* JSON encoding): - -```text -BenchmarkLogEmpty-8 100000000 19.1 ns/op 0 B/op 0 allocs/op -BenchmarkDisabled-8 500000000 4.07 ns/op 0 B/op 0 allocs/op -BenchmarkInfo-8 30000000 42.5 ns/op 0 B/op 0 allocs/op -BenchmarkContextFields-8 30000000 44.9 ns/op 0 B/op 0 allocs/op -BenchmarkLogFields-8 10000000 184 ns/op 0 B/op 0 allocs/op -``` - -There are a few Go logging benchmarks and comparisons that include zerolog. - -* [imkira/go-loggers-bench](https://github.com/imkira/go-loggers-bench) -* [uber-common/zap](https://github.com/uber-go/zap#performance) - -Using Uber's zap comparison benchmark: - -Log a message and 10 fields: - -| Library | Time | Bytes Allocated | Objects Allocated | -| :--- | :---: | :---: | :---: | -| zerolog | 767 ns/op | 552 B/op | 6 allocs/op | -| :zap: zap | 848 ns/op | 704 B/op | 2 allocs/op | -| :zap: zap (sugared) | 1363 ns/op | 1610 B/op | 20 allocs/op | -| go-kit | 3614 ns/op | 2895 B/op | 66 allocs/op | -| lion | 5392 ns/op | 5807 B/op | 63 allocs/op | -| logrus | 5661 ns/op | 6092 B/op | 78 allocs/op | -| apex/log | 15332 ns/op | 3832 B/op | 65 allocs/op | -| log15 | 20657 ns/op | 5632 B/op | 93 allocs/op | - -Log a message with a logger that already has 10 fields of context: - -| Library | Time | Bytes Allocated | Objects Allocated | -| :--- | :---: | :---: | :---: | -| zerolog | 52 ns/op | 0 B/op | 0 allocs/op | -| :zap: zap | 283 ns/op | 0 B/op | 0 allocs/op | -| :zap: zap (sugared) | 337 ns/op | 80 B/op | 2 allocs/op | -| lion | 2702 ns/op | 4074 B/op | 38 allocs/op | -| go-kit | 3378 ns/op | 3046 B/op | 52 allocs/op | -| logrus | 4309 ns/op | 4564 B/op | 63 allocs/op | -| apex/log | 13456 ns/op | 2898 B/op | 51 allocs/op | -| log15 | 14179 ns/op | 2642 B/op | 44 allocs/op | - -Log a static string, without any context or `printf`-style templating: - -| Library | Time | Bytes Allocated | Objects Allocated | -| :--- | :---: | :---: | :---: | -| zerolog | 50 ns/op | 0 B/op | 0 allocs/op | -| :zap: zap | 236 ns/op | 0 B/op | 0 allocs/op | -| standard library | 453 ns/op | 80 B/op | 2 allocs/op | -| :zap: zap (sugared) | 337 ns/op | 80 B/op | 2 allocs/op | -| go-kit | 508 ns/op | 656 B/op | 13 allocs/op | -| lion | 771 ns/op | 1224 B/op | 10 allocs/op | -| logrus | 1244 ns/op | 1505 B/op | 27 allocs/op | -| apex/log | 2751 ns/op | 584 B/op | 11 allocs/op | -| log15 | 5181 ns/op | 1592 B/op | 26 allocs/op | - -## Caveats - -Note that zerolog does no de-duplication of fields. Using the same key multiple times creates multiple keys in final JSON: - -```go -logger := zerolog.New(os.Stderr).With().Timestamp().Logger() -logger.Info(). - Timestamp(). - Msg("dup") -// Output: {"level":"info","time":1494567715,"time":1494567715,"message":"dup"} -``` - -In this case, many consumers will take the last value, but this is not guaranteed; check yours if in doubt. diff --git a/vendor/github.com/rs/zerolog/_config.yml b/vendor/github.com/rs/zerolog/_config.yml deleted file mode 100644 index a1e896d7..00000000 --- a/vendor/github.com/rs/zerolog/_config.yml +++ /dev/null @@ -1 +0,0 @@ -remote_theme: rs/gh-readme diff --git a/vendor/github.com/rs/zerolog/array.go b/vendor/github.com/rs/zerolog/array.go deleted file mode 100644 index c75c0520..00000000 --- a/vendor/github.com/rs/zerolog/array.go +++ /dev/null @@ -1,240 +0,0 @@ -package zerolog - -import ( - "net" - "sync" - "time" -) - -var arrayPool = &sync.Pool{ - New: func() interface{} { - return &Array{ - buf: make([]byte, 0, 500), - } - }, -} - -// Array is used to prepopulate an array of items -// which can be re-used to add to log messages. -type Array struct { - buf []byte -} - -func putArray(a *Array) { - // Proper usage of a sync.Pool requires each entry to have approximately - // the same memory cost. To obtain this property when the stored type - // contains a variably-sized buffer, we add a hard limit on the maximum buffer - // to place back in the pool. - // - // See https://golang.org/issue/23199 - const maxSize = 1 << 16 // 64KiB - if cap(a.buf) > maxSize { - return - } - arrayPool.Put(a) -} - -// Arr creates an array to be added to an Event or Context. -func Arr() *Array { - a := arrayPool.Get().(*Array) - a.buf = a.buf[:0] - return a -} - -// MarshalZerologArray method here is no-op - since data is -// already in the needed format. -func (*Array) MarshalZerologArray(*Array) { -} - -func (a *Array) write(dst []byte) []byte { - dst = enc.AppendArrayStart(dst) - if len(a.buf) > 0 { - dst = append(dst, a.buf...) - } - dst = enc.AppendArrayEnd(dst) - putArray(a) - return dst -} - -// Object marshals an object that implement the LogObjectMarshaler -// interface and append append it to the array. -func (a *Array) Object(obj LogObjectMarshaler) *Array { - e := Dict() - obj.MarshalZerologObject(e) - e.buf = enc.AppendEndMarker(e.buf) - a.buf = append(enc.AppendArrayDelim(a.buf), e.buf...) - putEvent(e) - return a -} - -// Str append append the val as a string to the array. -func (a *Array) Str(val string) *Array { - a.buf = enc.AppendString(enc.AppendArrayDelim(a.buf), val) - return a -} - -// Bytes append append the val as a string to the array. -func (a *Array) Bytes(val []byte) *Array { - a.buf = enc.AppendBytes(enc.AppendArrayDelim(a.buf), val) - return a -} - -// Hex append append the val as a hex string to the array. -func (a *Array) Hex(val []byte) *Array { - a.buf = enc.AppendHex(enc.AppendArrayDelim(a.buf), val) - return a -} - -// RawJSON adds already encoded JSON to the array. -func (a *Array) RawJSON(val []byte) *Array { - a.buf = appendJSON(enc.AppendArrayDelim(a.buf), val) - return a -} - -// Err serializes and appends the err to the array. -func (a *Array) Err(err error) *Array { - switch m := ErrorMarshalFunc(err).(type) { - case LogObjectMarshaler: - e := newEvent(nil, 0) - e.buf = e.buf[:0] - e.appendObject(m) - a.buf = append(enc.AppendArrayDelim(a.buf), e.buf...) - putEvent(e) - case error: - if m == nil || isNilValue(m) { - a.buf = enc.AppendNil(enc.AppendArrayDelim(a.buf)) - } else { - a.buf = enc.AppendString(enc.AppendArrayDelim(a.buf), m.Error()) - } - case string: - a.buf = enc.AppendString(enc.AppendArrayDelim(a.buf), m) - default: - a.buf = enc.AppendInterface(enc.AppendArrayDelim(a.buf), m) - } - - return a -} - -// Bool append append the val as a bool to the array. -func (a *Array) Bool(b bool) *Array { - a.buf = enc.AppendBool(enc.AppendArrayDelim(a.buf), b) - return a -} - -// Int append append i as a int to the array. -func (a *Array) Int(i int) *Array { - a.buf = enc.AppendInt(enc.AppendArrayDelim(a.buf), i) - return a -} - -// Int8 append append i as a int8 to the array. -func (a *Array) Int8(i int8) *Array { - a.buf = enc.AppendInt8(enc.AppendArrayDelim(a.buf), i) - return a -} - -// Int16 append append i as a int16 to the array. -func (a *Array) Int16(i int16) *Array { - a.buf = enc.AppendInt16(enc.AppendArrayDelim(a.buf), i) - return a -} - -// Int32 append append i as a int32 to the array. -func (a *Array) Int32(i int32) *Array { - a.buf = enc.AppendInt32(enc.AppendArrayDelim(a.buf), i) - return a -} - -// Int64 append append i as a int64 to the array. -func (a *Array) Int64(i int64) *Array { - a.buf = enc.AppendInt64(enc.AppendArrayDelim(a.buf), i) - return a -} - -// Uint append append i as a uint to the array. -func (a *Array) Uint(i uint) *Array { - a.buf = enc.AppendUint(enc.AppendArrayDelim(a.buf), i) - return a -} - -// Uint8 append append i as a uint8 to the array. -func (a *Array) Uint8(i uint8) *Array { - a.buf = enc.AppendUint8(enc.AppendArrayDelim(a.buf), i) - return a -} - -// Uint16 append append i as a uint16 to the array. -func (a *Array) Uint16(i uint16) *Array { - a.buf = enc.AppendUint16(enc.AppendArrayDelim(a.buf), i) - return a -} - -// Uint32 append append i as a uint32 to the array. -func (a *Array) Uint32(i uint32) *Array { - a.buf = enc.AppendUint32(enc.AppendArrayDelim(a.buf), i) - return a -} - -// Uint64 append append i as a uint64 to the array. -func (a *Array) Uint64(i uint64) *Array { - a.buf = enc.AppendUint64(enc.AppendArrayDelim(a.buf), i) - return a -} - -// Float32 append append f as a float32 to the array. -func (a *Array) Float32(f float32) *Array { - a.buf = enc.AppendFloat32(enc.AppendArrayDelim(a.buf), f) - return a -} - -// Float64 append append f as a float64 to the array. -func (a *Array) Float64(f float64) *Array { - a.buf = enc.AppendFloat64(enc.AppendArrayDelim(a.buf), f) - return a -} - -// Time append append t formatted as string using zerolog.TimeFieldFormat. -func (a *Array) Time(t time.Time) *Array { - a.buf = enc.AppendTime(enc.AppendArrayDelim(a.buf), t, TimeFieldFormat) - return a -} - -// Dur append append d to the array. -func (a *Array) Dur(d time.Duration) *Array { - a.buf = enc.AppendDuration(enc.AppendArrayDelim(a.buf), d, DurationFieldUnit, DurationFieldInteger) - return a -} - -// Interface append append i marshaled using reflection. -func (a *Array) Interface(i interface{}) *Array { - if obj, ok := i.(LogObjectMarshaler); ok { - return a.Object(obj) - } - a.buf = enc.AppendInterface(enc.AppendArrayDelim(a.buf), i) - return a -} - -// IPAddr adds IPv4 or IPv6 address to the array -func (a *Array) IPAddr(ip net.IP) *Array { - a.buf = enc.AppendIPAddr(enc.AppendArrayDelim(a.buf), ip) - return a -} - -// IPPrefix adds IPv4 or IPv6 Prefix (IP + mask) to the array -func (a *Array) IPPrefix(pfx net.IPNet) *Array { - a.buf = enc.AppendIPPrefix(enc.AppendArrayDelim(a.buf), pfx) - return a -} - -// MACAddr adds a MAC (Ethernet) address to the array -func (a *Array) MACAddr(ha net.HardwareAddr) *Array { - a.buf = enc.AppendMACAddr(enc.AppendArrayDelim(a.buf), ha) - return a -} - -// Dict adds the dict Event to the array -func (a *Array) Dict(dict *Event) *Array { - dict.buf = enc.AppendEndMarker(dict.buf) - a.buf = append(enc.AppendArrayDelim(a.buf), dict.buf...) - return a -} diff --git a/vendor/github.com/rs/zerolog/console.go b/vendor/github.com/rs/zerolog/console.go deleted file mode 100644 index ac34b7eb..00000000 --- a/vendor/github.com/rs/zerolog/console.go +++ /dev/null @@ -1,446 +0,0 @@ -package zerolog - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "os" - "path/filepath" - "sort" - "strconv" - "strings" - "sync" - "time" - - "github.com/mattn/go-colorable" -) - -const ( - colorBlack = iota + 30 - colorRed - colorGreen - colorYellow - colorBlue - colorMagenta - colorCyan - colorWhite - - colorBold = 1 - colorDarkGray = 90 -) - -var ( - consoleBufPool = sync.Pool{ - New: func() interface{} { - return bytes.NewBuffer(make([]byte, 0, 100)) - }, - } -) - -const ( - consoleDefaultTimeFormat = time.Kitchen -) - -// Formatter transforms the input into a formatted string. -type Formatter func(interface{}) string - -// ConsoleWriter parses the JSON input and writes it in an -// (optionally) colorized, human-friendly format to Out. -type ConsoleWriter struct { - // Out is the output destination. - Out io.Writer - - // NoColor disables the colorized output. - NoColor bool - - // TimeFormat specifies the format for timestamp in output. - TimeFormat string - - // PartsOrder defines the order of parts in output. - PartsOrder []string - - // PartsExclude defines parts to not display in output. - PartsExclude []string - - // FieldsExclude defines contextual fields to not display in output. - FieldsExclude []string - - FormatTimestamp Formatter - FormatLevel Formatter - FormatCaller Formatter - FormatMessage Formatter - FormatFieldName Formatter - FormatFieldValue Formatter - FormatErrFieldName Formatter - FormatErrFieldValue Formatter - - FormatExtra func(map[string]interface{}, *bytes.Buffer) error -} - -// NewConsoleWriter creates and initializes a new ConsoleWriter. -func NewConsoleWriter(options ...func(w *ConsoleWriter)) ConsoleWriter { - w := ConsoleWriter{ - Out: os.Stdout, - TimeFormat: consoleDefaultTimeFormat, - PartsOrder: consoleDefaultPartsOrder(), - } - - for _, opt := range options { - opt(&w) - } - - // Fix color on Windows - if w.Out == os.Stdout || w.Out == os.Stderr { - w.Out = colorable.NewColorable(w.Out.(*os.File)) - } - - return w -} - -// Write transforms the JSON input with formatters and appends to w.Out. -func (w ConsoleWriter) Write(p []byte) (n int, err error) { - // Fix color on Windows - if w.Out == os.Stdout || w.Out == os.Stderr { - w.Out = colorable.NewColorable(w.Out.(*os.File)) - } - - if w.PartsOrder == nil { - w.PartsOrder = consoleDefaultPartsOrder() - } - - var buf = consoleBufPool.Get().(*bytes.Buffer) - defer func() { - buf.Reset() - consoleBufPool.Put(buf) - }() - - var evt map[string]interface{} - p = decodeIfBinaryToBytes(p) - d := json.NewDecoder(bytes.NewReader(p)) - d.UseNumber() - err = d.Decode(&evt) - if err != nil { - return n, fmt.Errorf("cannot decode event: %s", err) - } - - for _, p := range w.PartsOrder { - w.writePart(buf, evt, p) - } - - w.writeFields(evt, buf) - - if w.FormatExtra != nil { - err = w.FormatExtra(evt, buf) - if err != nil { - return n, err - } - } - - err = buf.WriteByte('\n') - if err != nil { - return n, err - } - - _, err = buf.WriteTo(w.Out) - return len(p), err -} - -// writeFields appends formatted key-value pairs to buf. -func (w ConsoleWriter) writeFields(evt map[string]interface{}, buf *bytes.Buffer) { - var fields = make([]string, 0, len(evt)) - for field := range evt { - var isExcluded bool - for _, excluded := range w.FieldsExclude { - if field == excluded { - isExcluded = true - break - } - } - if isExcluded { - continue - } - - switch field { - case LevelFieldName, TimestampFieldName, MessageFieldName, CallerFieldName: - continue - } - fields = append(fields, field) - } - sort.Strings(fields) - - // Write space only if something has already been written to the buffer, and if there are fields. - if buf.Len() > 0 && len(fields) > 0 { - buf.WriteByte(' ') - } - - // Move the "error" field to the front - ei := sort.Search(len(fields), func(i int) bool { return fields[i] >= ErrorFieldName }) - if ei < len(fields) && fields[ei] == ErrorFieldName { - fields[ei] = "" - fields = append([]string{ErrorFieldName}, fields...) - var xfields = make([]string, 0, len(fields)) - for _, field := range fields { - if field == "" { // Skip empty fields - continue - } - xfields = append(xfields, field) - } - fields = xfields - } - - for i, field := range fields { - var fn Formatter - var fv Formatter - - if field == ErrorFieldName { - if w.FormatErrFieldName == nil { - fn = consoleDefaultFormatErrFieldName(w.NoColor) - } else { - fn = w.FormatErrFieldName - } - - if w.FormatErrFieldValue == nil { - fv = consoleDefaultFormatErrFieldValue(w.NoColor) - } else { - fv = w.FormatErrFieldValue - } - } else { - if w.FormatFieldName == nil { - fn = consoleDefaultFormatFieldName(w.NoColor) - } else { - fn = w.FormatFieldName - } - - if w.FormatFieldValue == nil { - fv = consoleDefaultFormatFieldValue - } else { - fv = w.FormatFieldValue - } - } - - buf.WriteString(fn(field)) - - switch fValue := evt[field].(type) { - case string: - if needsQuote(fValue) { - buf.WriteString(fv(strconv.Quote(fValue))) - } else { - buf.WriteString(fv(fValue)) - } - case json.Number: - buf.WriteString(fv(fValue)) - default: - b, err := InterfaceMarshalFunc(fValue) - if err != nil { - fmt.Fprintf(buf, colorize("[error: %v]", colorRed, w.NoColor), err) - } else { - fmt.Fprint(buf, fv(b)) - } - } - - if i < len(fields)-1 { // Skip space for last field - buf.WriteByte(' ') - } - } -} - -// writePart appends a formatted part to buf. -func (w ConsoleWriter) writePart(buf *bytes.Buffer, evt map[string]interface{}, p string) { - var f Formatter - - if w.PartsExclude != nil && len(w.PartsExclude) > 0 { - for _, exclude := range w.PartsExclude { - if exclude == p { - return - } - } - } - - switch p { - case LevelFieldName: - if w.FormatLevel == nil { - f = consoleDefaultFormatLevel(w.NoColor) - } else { - f = w.FormatLevel - } - case TimestampFieldName: - if w.FormatTimestamp == nil { - f = consoleDefaultFormatTimestamp(w.TimeFormat, w.NoColor) - } else { - f = w.FormatTimestamp - } - case MessageFieldName: - if w.FormatMessage == nil { - f = consoleDefaultFormatMessage - } else { - f = w.FormatMessage - } - case CallerFieldName: - if w.FormatCaller == nil { - f = consoleDefaultFormatCaller(w.NoColor) - } else { - f = w.FormatCaller - } - default: - if w.FormatFieldValue == nil { - f = consoleDefaultFormatFieldValue - } else { - f = w.FormatFieldValue - } - } - - var s = f(evt[p]) - - if len(s) > 0 { - if buf.Len() > 0 { - buf.WriteByte(' ') // Write space only if not the first part - } - buf.WriteString(s) - } -} - -// needsQuote returns true when the string s should be quoted in output. -func needsQuote(s string) bool { - for i := range s { - if s[i] < 0x20 || s[i] > 0x7e || s[i] == ' ' || s[i] == '\\' || s[i] == '"' { - return true - } - } - return false -} - -// colorize returns the string s wrapped in ANSI code c, unless disabled is true. -func colorize(s interface{}, c int, disabled bool) string { - if disabled { - return fmt.Sprintf("%s", s) - } - return fmt.Sprintf("\x1b[%dm%v\x1b[0m", c, s) -} - -// ----- DEFAULT FORMATTERS --------------------------------------------------- - -func consoleDefaultPartsOrder() []string { - return []string{ - TimestampFieldName, - LevelFieldName, - CallerFieldName, - MessageFieldName, - } -} - -func consoleDefaultFormatTimestamp(timeFormat string, noColor bool) Formatter { - if timeFormat == "" { - timeFormat = consoleDefaultTimeFormat - } - return func(i interface{}) string { - t := "" - switch tt := i.(type) { - case string: - ts, err := time.Parse(TimeFieldFormat, tt) - if err != nil { - t = tt - } else { - t = ts.Local().Format(timeFormat) - } - case json.Number: - i, err := tt.Int64() - if err != nil { - t = tt.String() - } else { - var sec, nsec int64 = i, 0 - switch TimeFieldFormat { - case TimeFormatUnixMs: - nsec = int64(time.Duration(i) * time.Millisecond) - sec = 0 - case TimeFormatUnixMicro: - nsec = int64(time.Duration(i) * time.Microsecond) - sec = 0 - } - ts := time.Unix(sec, nsec) - t = ts.Format(timeFormat) - } - } - return colorize(t, colorDarkGray, noColor) - } -} - -func consoleDefaultFormatLevel(noColor bool) Formatter { - return func(i interface{}) string { - var l string - if ll, ok := i.(string); ok { - switch ll { - case LevelTraceValue: - l = colorize("TRC", colorMagenta, noColor) - case LevelDebugValue: - l = colorize("DBG", colorYellow, noColor) - case LevelInfoValue: - l = colorize("INF", colorGreen, noColor) - case LevelWarnValue: - l = colorize("WRN", colorRed, noColor) - case LevelErrorValue: - l = colorize(colorize("ERR", colorRed, noColor), colorBold, noColor) - case LevelFatalValue: - l = colorize(colorize("FTL", colorRed, noColor), colorBold, noColor) - case LevelPanicValue: - l = colorize(colorize("PNC", colorRed, noColor), colorBold, noColor) - default: - l = colorize("???", colorBold, noColor) - } - } else { - if i == nil { - l = colorize("???", colorBold, noColor) - } else { - l = strings.ToUpper(fmt.Sprintf("%s", i))[0:3] - } - } - return l - } -} - -func consoleDefaultFormatCaller(noColor bool) Formatter { - return func(i interface{}) string { - var c string - if cc, ok := i.(string); ok { - c = cc - } - if len(c) > 0 { - if cwd, err := os.Getwd(); err == nil { - if rel, err := filepath.Rel(cwd, c); err == nil { - c = rel - } - } - c = colorize(c, colorBold, noColor) + colorize(" >", colorCyan, noColor) - } - return c - } -} - -func consoleDefaultFormatMessage(i interface{}) string { - if i == nil { - return "" - } - return fmt.Sprintf("%s", i) -} - -func consoleDefaultFormatFieldName(noColor bool) Formatter { - return func(i interface{}) string { - return colorize(fmt.Sprintf("%s=", i), colorCyan, noColor) - } -} - -func consoleDefaultFormatFieldValue(i interface{}) string { - return fmt.Sprintf("%s", i) -} - -func consoleDefaultFormatErrFieldName(noColor bool) Formatter { - return func(i interface{}) string { - return colorize(fmt.Sprintf("%s=", i), colorCyan, noColor) - } -} - -func consoleDefaultFormatErrFieldValue(noColor bool) Formatter { - return func(i interface{}) string { - return colorize(fmt.Sprintf("%s", i), colorRed, noColor) - } -} diff --git a/vendor/github.com/rs/zerolog/context.go b/vendor/github.com/rs/zerolog/context.go deleted file mode 100644 index f398e319..00000000 --- a/vendor/github.com/rs/zerolog/context.go +++ /dev/null @@ -1,433 +0,0 @@ -package zerolog - -import ( - "fmt" - "io/ioutil" - "math" - "net" - "time" -) - -// Context configures a new sub-logger with contextual fields. -type Context struct { - l Logger -} - -// Logger returns the logger with the context previously set. -func (c Context) Logger() Logger { - return c.l -} - -// Fields is a helper function to use a map or slice to set fields using type assertion. -// Only map[string]interface{} and []interface{} are accepted. []interface{} must -// alternate string keys and arbitrary values, and extraneous ones are ignored. -func (c Context) Fields(fields interface{}) Context { - c.l.context = appendFields(c.l.context, fields) - return c -} - -// Dict adds the field key with the dict to the logger context. -func (c Context) Dict(key string, dict *Event) Context { - dict.buf = enc.AppendEndMarker(dict.buf) - c.l.context = append(enc.AppendKey(c.l.context, key), dict.buf...) - putEvent(dict) - return c -} - -// Array adds the field key with an array to the event context. -// Use zerolog.Arr() to create the array or pass a type that -// implement the LogArrayMarshaler interface. -func (c Context) Array(key string, arr LogArrayMarshaler) Context { - c.l.context = enc.AppendKey(c.l.context, key) - if arr, ok := arr.(*Array); ok { - c.l.context = arr.write(c.l.context) - return c - } - var a *Array - if aa, ok := arr.(*Array); ok { - a = aa - } else { - a = Arr() - arr.MarshalZerologArray(a) - } - c.l.context = a.write(c.l.context) - return c -} - -// Object marshals an object that implement the LogObjectMarshaler interface. -func (c Context) Object(key string, obj LogObjectMarshaler) Context { - e := newEvent(levelWriterAdapter{ioutil.Discard}, 0) - e.Object(key, obj) - c.l.context = enc.AppendObjectData(c.l.context, e.buf) - putEvent(e) - return c -} - -// EmbedObject marshals and Embeds an object that implement the LogObjectMarshaler interface. -func (c Context) EmbedObject(obj LogObjectMarshaler) Context { - e := newEvent(levelWriterAdapter{ioutil.Discard}, 0) - e.EmbedObject(obj) - c.l.context = enc.AppendObjectData(c.l.context, e.buf) - putEvent(e) - return c -} - -// Str adds the field key with val as a string to the logger context. -func (c Context) Str(key, val string) Context { - c.l.context = enc.AppendString(enc.AppendKey(c.l.context, key), val) - return c -} - -// Strs adds the field key with val as a string to the logger context. -func (c Context) Strs(key string, vals []string) Context { - c.l.context = enc.AppendStrings(enc.AppendKey(c.l.context, key), vals) - return c -} - -// Stringer adds the field key with val.String() (or null if val is nil) to the logger context. -func (c Context) Stringer(key string, val fmt.Stringer) Context { - if val != nil { - c.l.context = enc.AppendString(enc.AppendKey(c.l.context, key), val.String()) - return c - } - - c.l.context = enc.AppendInterface(enc.AppendKey(c.l.context, key), nil) - return c -} - -// Bytes adds the field key with val as a []byte to the logger context. -func (c Context) Bytes(key string, val []byte) Context { - c.l.context = enc.AppendBytes(enc.AppendKey(c.l.context, key), val) - return c -} - -// Hex adds the field key with val as a hex string to the logger context. -func (c Context) Hex(key string, val []byte) Context { - c.l.context = enc.AppendHex(enc.AppendKey(c.l.context, key), val) - return c -} - -// RawJSON adds already encoded JSON to context. -// -// No sanity check is performed on b; it must not contain carriage returns and -// be valid JSON. -func (c Context) RawJSON(key string, b []byte) Context { - c.l.context = appendJSON(enc.AppendKey(c.l.context, key), b) - return c -} - -// AnErr adds the field key with serialized err to the logger context. -func (c Context) AnErr(key string, err error) Context { - switch m := ErrorMarshalFunc(err).(type) { - case nil: - return c - case LogObjectMarshaler: - return c.Object(key, m) - case error: - if m == nil || isNilValue(m) { - return c - } else { - return c.Str(key, m.Error()) - } - case string: - return c.Str(key, m) - default: - return c.Interface(key, m) - } -} - -// Errs adds the field key with errs as an array of serialized errors to the -// logger context. -func (c Context) Errs(key string, errs []error) Context { - arr := Arr() - for _, err := range errs { - switch m := ErrorMarshalFunc(err).(type) { - case LogObjectMarshaler: - arr = arr.Object(m) - case error: - if m == nil || isNilValue(m) { - arr = arr.Interface(nil) - } else { - arr = arr.Str(m.Error()) - } - case string: - arr = arr.Str(m) - default: - arr = arr.Interface(m) - } - } - - return c.Array(key, arr) -} - -// Err adds the field "error" with serialized err to the logger context. -func (c Context) Err(err error) Context { - return c.AnErr(ErrorFieldName, err) -} - -// Bool adds the field key with val as a bool to the logger context. -func (c Context) Bool(key string, b bool) Context { - c.l.context = enc.AppendBool(enc.AppendKey(c.l.context, key), b) - return c -} - -// Bools adds the field key with val as a []bool to the logger context. -func (c Context) Bools(key string, b []bool) Context { - c.l.context = enc.AppendBools(enc.AppendKey(c.l.context, key), b) - return c -} - -// Int adds the field key with i as a int to the logger context. -func (c Context) Int(key string, i int) Context { - c.l.context = enc.AppendInt(enc.AppendKey(c.l.context, key), i) - return c -} - -// Ints adds the field key with i as a []int to the logger context. -func (c Context) Ints(key string, i []int) Context { - c.l.context = enc.AppendInts(enc.AppendKey(c.l.context, key), i) - return c -} - -// Int8 adds the field key with i as a int8 to the logger context. -func (c Context) Int8(key string, i int8) Context { - c.l.context = enc.AppendInt8(enc.AppendKey(c.l.context, key), i) - return c -} - -// Ints8 adds the field key with i as a []int8 to the logger context. -func (c Context) Ints8(key string, i []int8) Context { - c.l.context = enc.AppendInts8(enc.AppendKey(c.l.context, key), i) - return c -} - -// Int16 adds the field key with i as a int16 to the logger context. -func (c Context) Int16(key string, i int16) Context { - c.l.context = enc.AppendInt16(enc.AppendKey(c.l.context, key), i) - return c -} - -// Ints16 adds the field key with i as a []int16 to the logger context. -func (c Context) Ints16(key string, i []int16) Context { - c.l.context = enc.AppendInts16(enc.AppendKey(c.l.context, key), i) - return c -} - -// Int32 adds the field key with i as a int32 to the logger context. -func (c Context) Int32(key string, i int32) Context { - c.l.context = enc.AppendInt32(enc.AppendKey(c.l.context, key), i) - return c -} - -// Ints32 adds the field key with i as a []int32 to the logger context. -func (c Context) Ints32(key string, i []int32) Context { - c.l.context = enc.AppendInts32(enc.AppendKey(c.l.context, key), i) - return c -} - -// Int64 adds the field key with i as a int64 to the logger context. -func (c Context) Int64(key string, i int64) Context { - c.l.context = enc.AppendInt64(enc.AppendKey(c.l.context, key), i) - return c -} - -// Ints64 adds the field key with i as a []int64 to the logger context. -func (c Context) Ints64(key string, i []int64) Context { - c.l.context = enc.AppendInts64(enc.AppendKey(c.l.context, key), i) - return c -} - -// Uint adds the field key with i as a uint to the logger context. -func (c Context) Uint(key string, i uint) Context { - c.l.context = enc.AppendUint(enc.AppendKey(c.l.context, key), i) - return c -} - -// Uints adds the field key with i as a []uint to the logger context. -func (c Context) Uints(key string, i []uint) Context { - c.l.context = enc.AppendUints(enc.AppendKey(c.l.context, key), i) - return c -} - -// Uint8 adds the field key with i as a uint8 to the logger context. -func (c Context) Uint8(key string, i uint8) Context { - c.l.context = enc.AppendUint8(enc.AppendKey(c.l.context, key), i) - return c -} - -// Uints8 adds the field key with i as a []uint8 to the logger context. -func (c Context) Uints8(key string, i []uint8) Context { - c.l.context = enc.AppendUints8(enc.AppendKey(c.l.context, key), i) - return c -} - -// Uint16 adds the field key with i as a uint16 to the logger context. -func (c Context) Uint16(key string, i uint16) Context { - c.l.context = enc.AppendUint16(enc.AppendKey(c.l.context, key), i) - return c -} - -// Uints16 adds the field key with i as a []uint16 to the logger context. -func (c Context) Uints16(key string, i []uint16) Context { - c.l.context = enc.AppendUints16(enc.AppendKey(c.l.context, key), i) - return c -} - -// Uint32 adds the field key with i as a uint32 to the logger context. -func (c Context) Uint32(key string, i uint32) Context { - c.l.context = enc.AppendUint32(enc.AppendKey(c.l.context, key), i) - return c -} - -// Uints32 adds the field key with i as a []uint32 to the logger context. -func (c Context) Uints32(key string, i []uint32) Context { - c.l.context = enc.AppendUints32(enc.AppendKey(c.l.context, key), i) - return c -} - -// Uint64 adds the field key with i as a uint64 to the logger context. -func (c Context) Uint64(key string, i uint64) Context { - c.l.context = enc.AppendUint64(enc.AppendKey(c.l.context, key), i) - return c -} - -// Uints64 adds the field key with i as a []uint64 to the logger context. -func (c Context) Uints64(key string, i []uint64) Context { - c.l.context = enc.AppendUints64(enc.AppendKey(c.l.context, key), i) - return c -} - -// Float32 adds the field key with f as a float32 to the logger context. -func (c Context) Float32(key string, f float32) Context { - c.l.context = enc.AppendFloat32(enc.AppendKey(c.l.context, key), f) - return c -} - -// Floats32 adds the field key with f as a []float32 to the logger context. -func (c Context) Floats32(key string, f []float32) Context { - c.l.context = enc.AppendFloats32(enc.AppendKey(c.l.context, key), f) - return c -} - -// Float64 adds the field key with f as a float64 to the logger context. -func (c Context) Float64(key string, f float64) Context { - c.l.context = enc.AppendFloat64(enc.AppendKey(c.l.context, key), f) - return c -} - -// Floats64 adds the field key with f as a []float64 to the logger context. -func (c Context) Floats64(key string, f []float64) Context { - c.l.context = enc.AppendFloats64(enc.AppendKey(c.l.context, key), f) - return c -} - -type timestampHook struct{} - -func (ts timestampHook) Run(e *Event, level Level, msg string) { - e.Timestamp() -} - -var th = timestampHook{} - -// Timestamp adds the current local time as UNIX timestamp to the logger context with the "time" key. -// To customize the key name, change zerolog.TimestampFieldName. -// -// NOTE: It won't dedupe the "time" key if the *Context has one already. -func (c Context) Timestamp() Context { - c.l = c.l.Hook(th) - return c -} - -// Time adds the field key with t formated as string using zerolog.TimeFieldFormat. -func (c Context) Time(key string, t time.Time) Context { - c.l.context = enc.AppendTime(enc.AppendKey(c.l.context, key), t, TimeFieldFormat) - return c -} - -// Times adds the field key with t formated as string using zerolog.TimeFieldFormat. -func (c Context) Times(key string, t []time.Time) Context { - c.l.context = enc.AppendTimes(enc.AppendKey(c.l.context, key), t, TimeFieldFormat) - return c -} - -// Dur adds the fields key with d divided by unit and stored as a float. -func (c Context) Dur(key string, d time.Duration) Context { - c.l.context = enc.AppendDuration(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger) - return c -} - -// Durs adds the fields key with d divided by unit and stored as a float. -func (c Context) Durs(key string, d []time.Duration) Context { - c.l.context = enc.AppendDurations(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger) - return c -} - -// Interface adds the field key with obj marshaled using reflection. -func (c Context) Interface(key string, i interface{}) Context { - c.l.context = enc.AppendInterface(enc.AppendKey(c.l.context, key), i) - return c -} - -type callerHook struct { - callerSkipFrameCount int -} - -func newCallerHook(skipFrameCount int) callerHook { - return callerHook{callerSkipFrameCount: skipFrameCount} -} - -func (ch callerHook) Run(e *Event, level Level, msg string) { - switch ch.callerSkipFrameCount { - case useGlobalSkipFrameCount: - // Extra frames to skip (added by hook infra). - e.caller(CallerSkipFrameCount + contextCallerSkipFrameCount) - default: - // Extra frames to skip (added by hook infra). - e.caller(ch.callerSkipFrameCount + contextCallerSkipFrameCount) - } -} - -// useGlobalSkipFrameCount acts as a flag to informat callerHook.Run -// to use the global CallerSkipFrameCount. -const useGlobalSkipFrameCount = math.MinInt32 - -// ch is the default caller hook using the global CallerSkipFrameCount. -var ch = newCallerHook(useGlobalSkipFrameCount) - -// Caller adds the file:line of the caller with the zerolog.CallerFieldName key. -func (c Context) Caller() Context { - c.l = c.l.Hook(ch) - return c -} - -// CallerWithSkipFrameCount adds the file:line of the caller with the zerolog.CallerFieldName key. -// The specified skipFrameCount int will override the global CallerSkipFrameCount for this context's respective logger. -// If set to -1 the global CallerSkipFrameCount will be used. -func (c Context) CallerWithSkipFrameCount(skipFrameCount int) Context { - c.l = c.l.Hook(newCallerHook(skipFrameCount)) - return c -} - -// Stack enables stack trace printing for the error passed to Err(). -func (c Context) Stack() Context { - c.l.stack = true - return c -} - -// IPAddr adds IPv4 or IPv6 Address to the context -func (c Context) IPAddr(key string, ip net.IP) Context { - c.l.context = enc.AppendIPAddr(enc.AppendKey(c.l.context, key), ip) - return c -} - -// IPPrefix adds IPv4 or IPv6 Prefix (address and mask) to the context -func (c Context) IPPrefix(key string, pfx net.IPNet) Context { - c.l.context = enc.AppendIPPrefix(enc.AppendKey(c.l.context, key), pfx) - return c -} - -// MACAddr adds MAC address to the context -func (c Context) MACAddr(key string, ha net.HardwareAddr) Context { - c.l.context = enc.AppendMACAddr(enc.AppendKey(c.l.context, key), ha) - return c -} diff --git a/vendor/github.com/rs/zerolog/ctx.go b/vendor/github.com/rs/zerolog/ctx.go deleted file mode 100644 index 44d3f4bc..00000000 --- a/vendor/github.com/rs/zerolog/ctx.go +++ /dev/null @@ -1,51 +0,0 @@ -package zerolog - -import ( - "context" -) - -var disabledLogger *Logger - -func init() { - SetGlobalLevel(TraceLevel) - l := Nop() - disabledLogger = &l -} - -type ctxKey struct{} - -// WithContext returns a copy of ctx with l associated. If an instance of Logger -// is already in the context, the context is not updated. -// -// For instance, to add a field to an existing logger in the context, use this -// notation: -// -// ctx := r.Context() -// l := zerolog.Ctx(ctx) -// l.UpdateContext(func(c Context) Context { -// return c.Str("bar", "baz") -// }) -func (l Logger) WithContext(ctx context.Context) context.Context { - if lp, ok := ctx.Value(ctxKey{}).(*Logger); ok { - if lp == &l { - // Do not store same logger. - return ctx - } - } else if l.level == Disabled { - // Do not store disabled logger. - return ctx - } - return context.WithValue(ctx, ctxKey{}, &l) -} - -// Ctx returns the Logger associated with the ctx. If no logger -// is associated, DefaultContextLogger is returned, unless DefaultContextLogger -// is nil, in which case a disabled logger is returned. -func Ctx(ctx context.Context) *Logger { - if l, ok := ctx.Value(ctxKey{}).(*Logger); ok { - return l - } else if l = DefaultContextLogger; l != nil { - return l - } - return disabledLogger -} diff --git a/vendor/github.com/rs/zerolog/encoder.go b/vendor/github.com/rs/zerolog/encoder.go deleted file mode 100644 index 09b24e80..00000000 --- a/vendor/github.com/rs/zerolog/encoder.go +++ /dev/null @@ -1,56 +0,0 @@ -package zerolog - -import ( - "net" - "time" -) - -type encoder interface { - AppendArrayDelim(dst []byte) []byte - AppendArrayEnd(dst []byte) []byte - AppendArrayStart(dst []byte) []byte - AppendBeginMarker(dst []byte) []byte - AppendBool(dst []byte, val bool) []byte - AppendBools(dst []byte, vals []bool) []byte - AppendBytes(dst, s []byte) []byte - AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte - AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte - AppendEndMarker(dst []byte) []byte - AppendFloat32(dst []byte, val float32) []byte - AppendFloat64(dst []byte, val float64) []byte - AppendFloats32(dst []byte, vals []float32) []byte - AppendFloats64(dst []byte, vals []float64) []byte - AppendHex(dst, s []byte) []byte - AppendIPAddr(dst []byte, ip net.IP) []byte - AppendIPPrefix(dst []byte, pfx net.IPNet) []byte - AppendInt(dst []byte, val int) []byte - AppendInt16(dst []byte, val int16) []byte - AppendInt32(dst []byte, val int32) []byte - AppendInt64(dst []byte, val int64) []byte - AppendInt8(dst []byte, val int8) []byte - AppendInterface(dst []byte, i interface{}) []byte - AppendInts(dst []byte, vals []int) []byte - AppendInts16(dst []byte, vals []int16) []byte - AppendInts32(dst []byte, vals []int32) []byte - AppendInts64(dst []byte, vals []int64) []byte - AppendInts8(dst []byte, vals []int8) []byte - AppendKey(dst []byte, key string) []byte - AppendLineBreak(dst []byte) []byte - AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte - AppendNil(dst []byte) []byte - AppendObjectData(dst []byte, o []byte) []byte - AppendString(dst []byte, s string) []byte - AppendStrings(dst []byte, vals []string) []byte - AppendTime(dst []byte, t time.Time, format string) []byte - AppendTimes(dst []byte, vals []time.Time, format string) []byte - AppendUint(dst []byte, val uint) []byte - AppendUint16(dst []byte, val uint16) []byte - AppendUint32(dst []byte, val uint32) []byte - AppendUint64(dst []byte, val uint64) []byte - AppendUint8(dst []byte, val uint8) []byte - AppendUints(dst []byte, vals []uint) []byte - AppendUints16(dst []byte, vals []uint16) []byte - AppendUints32(dst []byte, vals []uint32) []byte - AppendUints64(dst []byte, vals []uint64) []byte - AppendUints8(dst []byte, vals []uint8) []byte -} diff --git a/vendor/github.com/rs/zerolog/encoder_cbor.go b/vendor/github.com/rs/zerolog/encoder_cbor.go deleted file mode 100644 index 7b0dafef..00000000 --- a/vendor/github.com/rs/zerolog/encoder_cbor.go +++ /dev/null @@ -1,42 +0,0 @@ -// +build binary_log - -package zerolog - -// This file contains bindings to do binary encoding. - -import ( - "github.com/rs/zerolog/internal/cbor" -) - -var ( - _ encoder = (*cbor.Encoder)(nil) - - enc = cbor.Encoder{} -) - -func init() { - // using closure to reflect the changes at runtime. - cbor.JSONMarshalFunc = func(v interface{}) ([]byte, error) { - return InterfaceMarshalFunc(v) - } -} - -func appendJSON(dst []byte, j []byte) []byte { - return cbor.AppendEmbeddedJSON(dst, j) -} - -// decodeIfBinaryToString - converts a binary formatted log msg to a -// JSON formatted String Log message. -func decodeIfBinaryToString(in []byte) string { - return cbor.DecodeIfBinaryToString(in) -} - -func decodeObjectToStr(in []byte) string { - return cbor.DecodeObjectToStr(in) -} - -// decodeIfBinaryToBytes - converts a binary formatted log msg to a -// JSON formatted Bytes Log message. -func decodeIfBinaryToBytes(in []byte) []byte { - return cbor.DecodeIfBinaryToBytes(in) -} diff --git a/vendor/github.com/rs/zerolog/encoder_json.go b/vendor/github.com/rs/zerolog/encoder_json.go deleted file mode 100644 index 0e0450e2..00000000 --- a/vendor/github.com/rs/zerolog/encoder_json.go +++ /dev/null @@ -1,39 +0,0 @@ -// +build !binary_log - -package zerolog - -// encoder_json.go file contains bindings to generate -// JSON encoded byte stream. - -import ( - "github.com/rs/zerolog/internal/json" -) - -var ( - _ encoder = (*json.Encoder)(nil) - - enc = json.Encoder{} -) - -func init() { - // using closure to reflect the changes at runtime. - json.JSONMarshalFunc = func(v interface{}) ([]byte, error) { - return InterfaceMarshalFunc(v) - } -} - -func appendJSON(dst []byte, j []byte) []byte { - return append(dst, j...) -} - -func decodeIfBinaryToString(in []byte) string { - return string(in) -} - -func decodeObjectToStr(in []byte) string { - return string(in) -} - -func decodeIfBinaryToBytes(in []byte) []byte { - return in -} diff --git a/vendor/github.com/rs/zerolog/event.go b/vendor/github.com/rs/zerolog/event.go deleted file mode 100644 index 0e2eaa68..00000000 --- a/vendor/github.com/rs/zerolog/event.go +++ /dev/null @@ -1,780 +0,0 @@ -package zerolog - -import ( - "fmt" - "net" - "os" - "runtime" - "sync" - "time" -) - -var eventPool = &sync.Pool{ - New: func() interface{} { - return &Event{ - buf: make([]byte, 0, 500), - } - }, -} - -// Event represents a log event. It is instanced by one of the level method of -// Logger and finalized by the Msg or Msgf method. -type Event struct { - buf []byte - w LevelWriter - level Level - done func(msg string) - stack bool // enable error stack trace - ch []Hook // hooks from context - skipFrame int // The number of additional frames to skip when printing the caller. -} - -func putEvent(e *Event) { - // Proper usage of a sync.Pool requires each entry to have approximately - // the same memory cost. To obtain this property when the stored type - // contains a variably-sized buffer, we add a hard limit on the maximum buffer - // to place back in the pool. - // - // See https://golang.org/issue/23199 - const maxSize = 1 << 16 // 64KiB - if cap(e.buf) > maxSize { - return - } - eventPool.Put(e) -} - -// LogObjectMarshaler provides a strongly-typed and encoding-agnostic interface -// to be implemented by types used with Event/Context's Object methods. -type LogObjectMarshaler interface { - MarshalZerologObject(e *Event) -} - -// LogArrayMarshaler provides a strongly-typed and encoding-agnostic interface -// to be implemented by types used with Event/Context's Array methods. -type LogArrayMarshaler interface { - MarshalZerologArray(a *Array) -} - -func newEvent(w LevelWriter, level Level) *Event { - e := eventPool.Get().(*Event) - e.buf = e.buf[:0] - e.ch = nil - e.buf = enc.AppendBeginMarker(e.buf) - e.w = w - e.level = level - e.stack = false - e.skipFrame = 0 - return e -} - -func (e *Event) write() (err error) { - if e == nil { - return nil - } - if e.level != Disabled { - e.buf = enc.AppendEndMarker(e.buf) - e.buf = enc.AppendLineBreak(e.buf) - if e.w != nil { - _, err = e.w.WriteLevel(e.level, e.buf) - } - } - putEvent(e) - return -} - -// Enabled return false if the *Event is going to be filtered out by -// log level or sampling. -func (e *Event) Enabled() bool { - return e != nil && e.level != Disabled -} - -// Discard disables the event so Msg(f) won't print it. -func (e *Event) Discard() *Event { - if e == nil { - return e - } - e.level = Disabled - return nil -} - -// Msg sends the *Event with msg added as the message field if not empty. -// -// NOTICE: once this method is called, the *Event should be disposed. -// Calling Msg twice can have unexpected result. -func (e *Event) Msg(msg string) { - if e == nil { - return - } - e.msg(msg) -} - -// Send is equivalent to calling Msg(""). -// -// NOTICE: once this method is called, the *Event should be disposed. -func (e *Event) Send() { - if e == nil { - return - } - e.msg("") -} - -// Msgf sends the event with formatted msg added as the message field if not empty. -// -// NOTICE: once this method is called, the *Event should be disposed. -// Calling Msgf twice can have unexpected result. -func (e *Event) Msgf(format string, v ...interface{}) { - if e == nil { - return - } - e.msg(fmt.Sprintf(format, v...)) -} - -func (e *Event) MsgFunc(createMsg func() string) { - if e == nil { - return - } - e.msg(createMsg()) -} - -func (e *Event) msg(msg string) { - for _, hook := range e.ch { - hook.Run(e, e.level, msg) - } - if msg != "" { - e.buf = enc.AppendString(enc.AppendKey(e.buf, MessageFieldName), msg) - } - if e.done != nil { - defer e.done(msg) - } - if err := e.write(); err != nil { - if ErrorHandler != nil { - ErrorHandler(err) - } else { - fmt.Fprintf(os.Stderr, "zerolog: could not write event: %v\n", err) - } - } -} - -// Fields is a helper function to use a map or slice to set fields using type assertion. -// Only map[string]interface{} and []interface{} are accepted. []interface{} must -// alternate string keys and arbitrary values, and extraneous ones are ignored. -func (e *Event) Fields(fields interface{}) *Event { - if e == nil { - return e - } - e.buf = appendFields(e.buf, fields) - return e -} - -// Dict adds the field key with a dict to the event context. -// Use zerolog.Dict() to create the dictionary. -func (e *Event) Dict(key string, dict *Event) *Event { - if e == nil { - return e - } - dict.buf = enc.AppendEndMarker(dict.buf) - e.buf = append(enc.AppendKey(e.buf, key), dict.buf...) - putEvent(dict) - return e -} - -// Dict creates an Event to be used with the *Event.Dict method. -// Call usual field methods like Str, Int etc to add fields to this -// event and give it as argument the *Event.Dict method. -func Dict() *Event { - return newEvent(nil, 0) -} - -// Array adds the field key with an array to the event context. -// Use zerolog.Arr() to create the array or pass a type that -// implement the LogArrayMarshaler interface. -func (e *Event) Array(key string, arr LogArrayMarshaler) *Event { - if e == nil { - return e - } - e.buf = enc.AppendKey(e.buf, key) - var a *Array - if aa, ok := arr.(*Array); ok { - a = aa - } else { - a = Arr() - arr.MarshalZerologArray(a) - } - e.buf = a.write(e.buf) - return e -} - -func (e *Event) appendObject(obj LogObjectMarshaler) { - e.buf = enc.AppendBeginMarker(e.buf) - obj.MarshalZerologObject(e) - e.buf = enc.AppendEndMarker(e.buf) -} - -// Object marshals an object that implement the LogObjectMarshaler interface. -func (e *Event) Object(key string, obj LogObjectMarshaler) *Event { - if e == nil { - return e - } - e.buf = enc.AppendKey(e.buf, key) - if obj == nil { - e.buf = enc.AppendNil(e.buf) - - return e - } - - e.appendObject(obj) - return e -} - -// Func allows an anonymous func to run only if the event is enabled. -func (e *Event) Func(f func(e *Event)) *Event { - if e != nil && e.Enabled() { - f(e) - } - return e -} - -// EmbedObject marshals an object that implement the LogObjectMarshaler interface. -func (e *Event) EmbedObject(obj LogObjectMarshaler) *Event { - if e == nil { - return e - } - if obj == nil { - return e - } - obj.MarshalZerologObject(e) - return e -} - -// Str adds the field key with val as a string to the *Event context. -func (e *Event) Str(key, val string) *Event { - if e == nil { - return e - } - e.buf = enc.AppendString(enc.AppendKey(e.buf, key), val) - return e -} - -// Strs adds the field key with vals as a []string to the *Event context. -func (e *Event) Strs(key string, vals []string) *Event { - if e == nil { - return e - } - e.buf = enc.AppendStrings(enc.AppendKey(e.buf, key), vals) - return e -} - -// Stringer adds the field key with val.String() (or null if val is nil) -// to the *Event context. -func (e *Event) Stringer(key string, val fmt.Stringer) *Event { - if e == nil { - return e - } - e.buf = enc.AppendStringer(enc.AppendKey(e.buf, key), val) - return e -} - -// Stringers adds the field key with vals where each individual val -// is used as val.String() (or null if val is empty) to the *Event -// context. -func (e *Event) Stringers(key string, vals []fmt.Stringer) *Event { - if e == nil { - return e - } - e.buf = enc.AppendStringers(enc.AppendKey(e.buf, key), vals) - return e -} - -// Bytes adds the field key with val as a string to the *Event context. -// -// Runes outside of normal ASCII ranges will be hex-encoded in the resulting -// JSON. -func (e *Event) Bytes(key string, val []byte) *Event { - if e == nil { - return e - } - e.buf = enc.AppendBytes(enc.AppendKey(e.buf, key), val) - return e -} - -// Hex adds the field key with val as a hex string to the *Event context. -func (e *Event) Hex(key string, val []byte) *Event { - if e == nil { - return e - } - e.buf = enc.AppendHex(enc.AppendKey(e.buf, key), val) - return e -} - -// RawJSON adds already encoded JSON to the log line under key. -// -// No sanity check is performed on b; it must not contain carriage returns and -// be valid JSON. -func (e *Event) RawJSON(key string, b []byte) *Event { - if e == nil { - return e - } - e.buf = appendJSON(enc.AppendKey(e.buf, key), b) - return e -} - -// AnErr adds the field key with serialized err to the *Event context. -// If err is nil, no field is added. -func (e *Event) AnErr(key string, err error) *Event { - if e == nil { - return e - } - switch m := ErrorMarshalFunc(err).(type) { - case nil: - return e - case LogObjectMarshaler: - return e.Object(key, m) - case error: - if m == nil || isNilValue(m) { - return e - } else { - return e.Str(key, m.Error()) - } - case string: - return e.Str(key, m) - default: - return e.Interface(key, m) - } -} - -// Errs adds the field key with errs as an array of serialized errors to the -// *Event context. -func (e *Event) Errs(key string, errs []error) *Event { - if e == nil { - return e - } - arr := Arr() - for _, err := range errs { - switch m := ErrorMarshalFunc(err).(type) { - case LogObjectMarshaler: - arr = arr.Object(m) - case error: - arr = arr.Err(m) - case string: - arr = arr.Str(m) - default: - arr = arr.Interface(m) - } - } - - return e.Array(key, arr) -} - -// Err adds the field "error" with serialized err to the *Event context. -// If err is nil, no field is added. -// -// To customize the key name, change zerolog.ErrorFieldName. -// -// If Stack() has been called before and zerolog.ErrorStackMarshaler is defined, -// the err is passed to ErrorStackMarshaler and the result is appended to the -// zerolog.ErrorStackFieldName. -func (e *Event) Err(err error) *Event { - if e == nil { - return e - } - if e.stack && ErrorStackMarshaler != nil { - switch m := ErrorStackMarshaler(err).(type) { - case nil: - case LogObjectMarshaler: - e.Object(ErrorStackFieldName, m) - case error: - if m != nil && !isNilValue(m) { - e.Str(ErrorStackFieldName, m.Error()) - } - case string: - e.Str(ErrorStackFieldName, m) - default: - e.Interface(ErrorStackFieldName, m) - } - } - return e.AnErr(ErrorFieldName, err) -} - -// Stack enables stack trace printing for the error passed to Err(). -// -// ErrorStackMarshaler must be set for this method to do something. -func (e *Event) Stack() *Event { - if e != nil { - e.stack = true - } - return e -} - -// Bool adds the field key with val as a bool to the *Event context. -func (e *Event) Bool(key string, b bool) *Event { - if e == nil { - return e - } - e.buf = enc.AppendBool(enc.AppendKey(e.buf, key), b) - return e -} - -// Bools adds the field key with val as a []bool to the *Event context. -func (e *Event) Bools(key string, b []bool) *Event { - if e == nil { - return e - } - e.buf = enc.AppendBools(enc.AppendKey(e.buf, key), b) - return e -} - -// Int adds the field key with i as a int to the *Event context. -func (e *Event) Int(key string, i int) *Event { - if e == nil { - return e - } - e.buf = enc.AppendInt(enc.AppendKey(e.buf, key), i) - return e -} - -// Ints adds the field key with i as a []int to the *Event context. -func (e *Event) Ints(key string, i []int) *Event { - if e == nil { - return e - } - e.buf = enc.AppendInts(enc.AppendKey(e.buf, key), i) - return e -} - -// Int8 adds the field key with i as a int8 to the *Event context. -func (e *Event) Int8(key string, i int8) *Event { - if e == nil { - return e - } - e.buf = enc.AppendInt8(enc.AppendKey(e.buf, key), i) - return e -} - -// Ints8 adds the field key with i as a []int8 to the *Event context. -func (e *Event) Ints8(key string, i []int8) *Event { - if e == nil { - return e - } - e.buf = enc.AppendInts8(enc.AppendKey(e.buf, key), i) - return e -} - -// Int16 adds the field key with i as a int16 to the *Event context. -func (e *Event) Int16(key string, i int16) *Event { - if e == nil { - return e - } - e.buf = enc.AppendInt16(enc.AppendKey(e.buf, key), i) - return e -} - -// Ints16 adds the field key with i as a []int16 to the *Event context. -func (e *Event) Ints16(key string, i []int16) *Event { - if e == nil { - return e - } - e.buf = enc.AppendInts16(enc.AppendKey(e.buf, key), i) - return e -} - -// Int32 adds the field key with i as a int32 to the *Event context. -func (e *Event) Int32(key string, i int32) *Event { - if e == nil { - return e - } - e.buf = enc.AppendInt32(enc.AppendKey(e.buf, key), i) - return e -} - -// Ints32 adds the field key with i as a []int32 to the *Event context. -func (e *Event) Ints32(key string, i []int32) *Event { - if e == nil { - return e - } - e.buf = enc.AppendInts32(enc.AppendKey(e.buf, key), i) - return e -} - -// Int64 adds the field key with i as a int64 to the *Event context. -func (e *Event) Int64(key string, i int64) *Event { - if e == nil { - return e - } - e.buf = enc.AppendInt64(enc.AppendKey(e.buf, key), i) - return e -} - -// Ints64 adds the field key with i as a []int64 to the *Event context. -func (e *Event) Ints64(key string, i []int64) *Event { - if e == nil { - return e - } - e.buf = enc.AppendInts64(enc.AppendKey(e.buf, key), i) - return e -} - -// Uint adds the field key with i as a uint to the *Event context. -func (e *Event) Uint(key string, i uint) *Event { - if e == nil { - return e - } - e.buf = enc.AppendUint(enc.AppendKey(e.buf, key), i) - return e -} - -// Uints adds the field key with i as a []int to the *Event context. -func (e *Event) Uints(key string, i []uint) *Event { - if e == nil { - return e - } - e.buf = enc.AppendUints(enc.AppendKey(e.buf, key), i) - return e -} - -// Uint8 adds the field key with i as a uint8 to the *Event context. -func (e *Event) Uint8(key string, i uint8) *Event { - if e == nil { - return e - } - e.buf = enc.AppendUint8(enc.AppendKey(e.buf, key), i) - return e -} - -// Uints8 adds the field key with i as a []int8 to the *Event context. -func (e *Event) Uints8(key string, i []uint8) *Event { - if e == nil { - return e - } - e.buf = enc.AppendUints8(enc.AppendKey(e.buf, key), i) - return e -} - -// Uint16 adds the field key with i as a uint16 to the *Event context. -func (e *Event) Uint16(key string, i uint16) *Event { - if e == nil { - return e - } - e.buf = enc.AppendUint16(enc.AppendKey(e.buf, key), i) - return e -} - -// Uints16 adds the field key with i as a []int16 to the *Event context. -func (e *Event) Uints16(key string, i []uint16) *Event { - if e == nil { - return e - } - e.buf = enc.AppendUints16(enc.AppendKey(e.buf, key), i) - return e -} - -// Uint32 adds the field key with i as a uint32 to the *Event context. -func (e *Event) Uint32(key string, i uint32) *Event { - if e == nil { - return e - } - e.buf = enc.AppendUint32(enc.AppendKey(e.buf, key), i) - return e -} - -// Uints32 adds the field key with i as a []int32 to the *Event context. -func (e *Event) Uints32(key string, i []uint32) *Event { - if e == nil { - return e - } - e.buf = enc.AppendUints32(enc.AppendKey(e.buf, key), i) - return e -} - -// Uint64 adds the field key with i as a uint64 to the *Event context. -func (e *Event) Uint64(key string, i uint64) *Event { - if e == nil { - return e - } - e.buf = enc.AppendUint64(enc.AppendKey(e.buf, key), i) - return e -} - -// Uints64 adds the field key with i as a []int64 to the *Event context. -func (e *Event) Uints64(key string, i []uint64) *Event { - if e == nil { - return e - } - e.buf = enc.AppendUints64(enc.AppendKey(e.buf, key), i) - return e -} - -// Float32 adds the field key with f as a float32 to the *Event context. -func (e *Event) Float32(key string, f float32) *Event { - if e == nil { - return e - } - e.buf = enc.AppendFloat32(enc.AppendKey(e.buf, key), f) - return e -} - -// Floats32 adds the field key with f as a []float32 to the *Event context. -func (e *Event) Floats32(key string, f []float32) *Event { - if e == nil { - return e - } - e.buf = enc.AppendFloats32(enc.AppendKey(e.buf, key), f) - return e -} - -// Float64 adds the field key with f as a float64 to the *Event context. -func (e *Event) Float64(key string, f float64) *Event { - if e == nil { - return e - } - e.buf = enc.AppendFloat64(enc.AppendKey(e.buf, key), f) - return e -} - -// Floats64 adds the field key with f as a []float64 to the *Event context. -func (e *Event) Floats64(key string, f []float64) *Event { - if e == nil { - return e - } - e.buf = enc.AppendFloats64(enc.AppendKey(e.buf, key), f) - return e -} - -// Timestamp adds the current local time as UNIX timestamp to the *Event context with the "time" key. -// To customize the key name, change zerolog.TimestampFieldName. -// -// NOTE: It won't dedupe the "time" key if the *Event (or *Context) has one -// already. -func (e *Event) Timestamp() *Event { - if e == nil { - return e - } - e.buf = enc.AppendTime(enc.AppendKey(e.buf, TimestampFieldName), TimestampFunc(), TimeFieldFormat) - return e -} - -// Time adds the field key with t formatted as string using zerolog.TimeFieldFormat. -func (e *Event) Time(key string, t time.Time) *Event { - if e == nil { - return e - } - e.buf = enc.AppendTime(enc.AppendKey(e.buf, key), t, TimeFieldFormat) - return e -} - -// Times adds the field key with t formatted as string using zerolog.TimeFieldFormat. -func (e *Event) Times(key string, t []time.Time) *Event { - if e == nil { - return e - } - e.buf = enc.AppendTimes(enc.AppendKey(e.buf, key), t, TimeFieldFormat) - return e -} - -// Dur adds the field key with duration d stored as zerolog.DurationFieldUnit. -// If zerolog.DurationFieldInteger is true, durations are rendered as integer -// instead of float. -func (e *Event) Dur(key string, d time.Duration) *Event { - if e == nil { - return e - } - e.buf = enc.AppendDuration(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger) - return e -} - -// Durs adds the field key with duration d stored as zerolog.DurationFieldUnit. -// If zerolog.DurationFieldInteger is true, durations are rendered as integer -// instead of float. -func (e *Event) Durs(key string, d []time.Duration) *Event { - if e == nil { - return e - } - e.buf = enc.AppendDurations(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger) - return e -} - -// TimeDiff adds the field key with positive duration between time t and start. -// If time t is not greater than start, duration will be 0. -// Duration format follows the same principle as Dur(). -func (e *Event) TimeDiff(key string, t time.Time, start time.Time) *Event { - if e == nil { - return e - } - var d time.Duration - if t.After(start) { - d = t.Sub(start) - } - e.buf = enc.AppendDuration(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger) - return e -} - -// Interface adds the field key with i marshaled using reflection. -func (e *Event) Interface(key string, i interface{}) *Event { - if e == nil { - return e - } - if obj, ok := i.(LogObjectMarshaler); ok { - return e.Object(key, obj) - } - e.buf = enc.AppendInterface(enc.AppendKey(e.buf, key), i) - return e -} - -// CallerSkipFrame instructs any future Caller calls to skip the specified number of frames. -// This includes those added via hooks from the context. -func (e *Event) CallerSkipFrame(skip int) *Event { - if e == nil { - return e - } - e.skipFrame += skip - return e -} - -// Caller adds the file:line of the caller with the zerolog.CallerFieldName key. -// The argument skip is the number of stack frames to ascend -// Skip If not passed, use the global variable CallerSkipFrameCount -func (e *Event) Caller(skip ...int) *Event { - sk := CallerSkipFrameCount - if len(skip) > 0 { - sk = skip[0] + CallerSkipFrameCount - } - return e.caller(sk) -} - -func (e *Event) caller(skip int) *Event { - if e == nil { - return e - } - pc, file, line, ok := runtime.Caller(skip + e.skipFrame) - if !ok { - return e - } - e.buf = enc.AppendString(enc.AppendKey(e.buf, CallerFieldName), CallerMarshalFunc(pc, file, line)) - return e -} - -// IPAddr adds IPv4 or IPv6 Address to the event -func (e *Event) IPAddr(key string, ip net.IP) *Event { - if e == nil { - return e - } - e.buf = enc.AppendIPAddr(enc.AppendKey(e.buf, key), ip) - return e -} - -// IPPrefix adds IPv4 or IPv6 Prefix (address and mask) to the event -func (e *Event) IPPrefix(key string, pfx net.IPNet) *Event { - if e == nil { - return e - } - e.buf = enc.AppendIPPrefix(enc.AppendKey(e.buf, key), pfx) - return e -} - -// MACAddr adds MAC address to the event -func (e *Event) MACAddr(key string, ha net.HardwareAddr) *Event { - if e == nil { - return e - } - e.buf = enc.AppendMACAddr(enc.AppendKey(e.buf, key), ha) - return e -} diff --git a/vendor/github.com/rs/zerolog/fields.go b/vendor/github.com/rs/zerolog/fields.go deleted file mode 100644 index c1eb5ce7..00000000 --- a/vendor/github.com/rs/zerolog/fields.go +++ /dev/null @@ -1,277 +0,0 @@ -package zerolog - -import ( - "encoding/json" - "net" - "sort" - "time" - "unsafe" -) - -func isNilValue(i interface{}) bool { - return (*[2]uintptr)(unsafe.Pointer(&i))[1] == 0 -} - -func appendFields(dst []byte, fields interface{}) []byte { - switch fields := fields.(type) { - case []interface{}: - if n := len(fields); n&0x1 == 1 { // odd number - fields = fields[:n-1] - } - dst = appendFieldList(dst, fields) - case map[string]interface{}: - keys := make([]string, 0, len(fields)) - for key := range fields { - keys = append(keys, key) - } - sort.Strings(keys) - kv := make([]interface{}, 2) - for _, key := range keys { - kv[0], kv[1] = key, fields[key] - dst = appendFieldList(dst, kv) - } - } - return dst -} - -func appendFieldList(dst []byte, kvList []interface{}) []byte { - for i, n := 0, len(kvList); i < n; i += 2 { - key, val := kvList[i], kvList[i+1] - if key, ok := key.(string); ok { - dst = enc.AppendKey(dst, key) - } else { - continue - } - if val, ok := val.(LogObjectMarshaler); ok { - e := newEvent(nil, 0) - e.buf = e.buf[:0] - e.appendObject(val) - dst = append(dst, e.buf...) - putEvent(e) - continue - } - switch val := val.(type) { - case string: - dst = enc.AppendString(dst, val) - case []byte: - dst = enc.AppendBytes(dst, val) - case error: - switch m := ErrorMarshalFunc(val).(type) { - case LogObjectMarshaler: - e := newEvent(nil, 0) - e.buf = e.buf[:0] - e.appendObject(m) - dst = append(dst, e.buf...) - putEvent(e) - case error: - if m == nil || isNilValue(m) { - dst = enc.AppendNil(dst) - } else { - dst = enc.AppendString(dst, m.Error()) - } - case string: - dst = enc.AppendString(dst, m) - default: - dst = enc.AppendInterface(dst, m) - } - case []error: - dst = enc.AppendArrayStart(dst) - for i, err := range val { - switch m := ErrorMarshalFunc(err).(type) { - case LogObjectMarshaler: - e := newEvent(nil, 0) - e.buf = e.buf[:0] - e.appendObject(m) - dst = append(dst, e.buf...) - putEvent(e) - case error: - if m == nil || isNilValue(m) { - dst = enc.AppendNil(dst) - } else { - dst = enc.AppendString(dst, m.Error()) - } - case string: - dst = enc.AppendString(dst, m) - default: - dst = enc.AppendInterface(dst, m) - } - - if i < (len(val) - 1) { - enc.AppendArrayDelim(dst) - } - } - dst = enc.AppendArrayEnd(dst) - case bool: - dst = enc.AppendBool(dst, val) - case int: - dst = enc.AppendInt(dst, val) - case int8: - dst = enc.AppendInt8(dst, val) - case int16: - dst = enc.AppendInt16(dst, val) - case int32: - dst = enc.AppendInt32(dst, val) - case int64: - dst = enc.AppendInt64(dst, val) - case uint: - dst = enc.AppendUint(dst, val) - case uint8: - dst = enc.AppendUint8(dst, val) - case uint16: - dst = enc.AppendUint16(dst, val) - case uint32: - dst = enc.AppendUint32(dst, val) - case uint64: - dst = enc.AppendUint64(dst, val) - case float32: - dst = enc.AppendFloat32(dst, val) - case float64: - dst = enc.AppendFloat64(dst, val) - case time.Time: - dst = enc.AppendTime(dst, val, TimeFieldFormat) - case time.Duration: - dst = enc.AppendDuration(dst, val, DurationFieldUnit, DurationFieldInteger) - case *string: - if val != nil { - dst = enc.AppendString(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *bool: - if val != nil { - dst = enc.AppendBool(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *int: - if val != nil { - dst = enc.AppendInt(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *int8: - if val != nil { - dst = enc.AppendInt8(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *int16: - if val != nil { - dst = enc.AppendInt16(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *int32: - if val != nil { - dst = enc.AppendInt32(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *int64: - if val != nil { - dst = enc.AppendInt64(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *uint: - if val != nil { - dst = enc.AppendUint(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *uint8: - if val != nil { - dst = enc.AppendUint8(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *uint16: - if val != nil { - dst = enc.AppendUint16(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *uint32: - if val != nil { - dst = enc.AppendUint32(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *uint64: - if val != nil { - dst = enc.AppendUint64(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *float32: - if val != nil { - dst = enc.AppendFloat32(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *float64: - if val != nil { - dst = enc.AppendFloat64(dst, *val) - } else { - dst = enc.AppendNil(dst) - } - case *time.Time: - if val != nil { - dst = enc.AppendTime(dst, *val, TimeFieldFormat) - } else { - dst = enc.AppendNil(dst) - } - case *time.Duration: - if val != nil { - dst = enc.AppendDuration(dst, *val, DurationFieldUnit, DurationFieldInteger) - } else { - dst = enc.AppendNil(dst) - } - case []string: - dst = enc.AppendStrings(dst, val) - case []bool: - dst = enc.AppendBools(dst, val) - case []int: - dst = enc.AppendInts(dst, val) - case []int8: - dst = enc.AppendInts8(dst, val) - case []int16: - dst = enc.AppendInts16(dst, val) - case []int32: - dst = enc.AppendInts32(dst, val) - case []int64: - dst = enc.AppendInts64(dst, val) - case []uint: - dst = enc.AppendUints(dst, val) - // case []uint8: - // dst = enc.AppendUints8(dst, val) - case []uint16: - dst = enc.AppendUints16(dst, val) - case []uint32: - dst = enc.AppendUints32(dst, val) - case []uint64: - dst = enc.AppendUints64(dst, val) - case []float32: - dst = enc.AppendFloats32(dst, val) - case []float64: - dst = enc.AppendFloats64(dst, val) - case []time.Time: - dst = enc.AppendTimes(dst, val, TimeFieldFormat) - case []time.Duration: - dst = enc.AppendDurations(dst, val, DurationFieldUnit, DurationFieldInteger) - case nil: - dst = enc.AppendNil(dst) - case net.IP: - dst = enc.AppendIPAddr(dst, val) - case net.IPNet: - dst = enc.AppendIPPrefix(dst, val) - case net.HardwareAddr: - dst = enc.AppendMACAddr(dst, val) - case json.RawMessage: - dst = appendJSON(dst, val) - default: - dst = enc.AppendInterface(dst, val) - } - } - return dst -} diff --git a/vendor/github.com/rs/zerolog/globals.go b/vendor/github.com/rs/zerolog/globals.go deleted file mode 100644 index e1067deb..00000000 --- a/vendor/github.com/rs/zerolog/globals.go +++ /dev/null @@ -1,142 +0,0 @@ -package zerolog - -import ( - "encoding/json" - "strconv" - "sync/atomic" - "time" -) - -const ( - // TimeFormatUnix defines a time format that makes time fields to be - // serialized as Unix timestamp integers. - TimeFormatUnix = "" - - // TimeFormatUnixMs defines a time format that makes time fields to be - // serialized as Unix timestamp integers in milliseconds. - TimeFormatUnixMs = "UNIXMS" - - // TimeFormatUnixMicro defines a time format that makes time fields to be - // serialized as Unix timestamp integers in microseconds. - TimeFormatUnixMicro = "UNIXMICRO" - - // TimeFormatUnixNano defines a time format that makes time fields to be - // serialized as Unix timestamp integers in nanoseconds. - TimeFormatUnixNano = "UNIXNANO" -) - -var ( - // TimestampFieldName is the field name used for the timestamp field. - TimestampFieldName = "time" - - // LevelFieldName is the field name used for the level field. - LevelFieldName = "level" - - // LevelTraceValue is the value used for the trace level field. - LevelTraceValue = "trace" - // LevelDebugValue is the value used for the debug level field. - LevelDebugValue = "debug" - // LevelInfoValue is the value used for the info level field. - LevelInfoValue = "info" - // LevelWarnValue is the value used for the warn level field. - LevelWarnValue = "warn" - // LevelErrorValue is the value used for the error level field. - LevelErrorValue = "error" - // LevelFatalValue is the value used for the fatal level field. - LevelFatalValue = "fatal" - // LevelPanicValue is the value used for the panic level field. - LevelPanicValue = "panic" - - // LevelFieldMarshalFunc allows customization of global level field marshaling. - LevelFieldMarshalFunc = func(l Level) string { - return l.String() - } - - // MessageFieldName is the field name used for the message field. - MessageFieldName = "message" - - // ErrorFieldName is the field name used for error fields. - ErrorFieldName = "error" - - // CallerFieldName is the field name used for caller field. - CallerFieldName = "caller" - - // CallerSkipFrameCount is the number of stack frames to skip to find the caller. - CallerSkipFrameCount = 2 - - // CallerMarshalFunc allows customization of global caller marshaling - CallerMarshalFunc = func(pc uintptr, file string, line int) string { - return file + ":" + strconv.Itoa(line) - } - - // ErrorStackFieldName is the field name used for error stacks. - ErrorStackFieldName = "stack" - - // ErrorStackMarshaler extract the stack from err if any. - ErrorStackMarshaler func(err error) interface{} - - // ErrorMarshalFunc allows customization of global error marshaling - ErrorMarshalFunc = func(err error) interface{} { - return err - } - - // InterfaceMarshalFunc allows customization of interface marshaling. - // Default: "encoding/json.Marshal" - InterfaceMarshalFunc = json.Marshal - - // TimeFieldFormat defines the time format of the Time field type. If set to - // TimeFormatUnix, TimeFormatUnixMs, TimeFormatUnixMicro or TimeFormatUnixNano, the time is formatted as a UNIX - // timestamp as integer. - TimeFieldFormat = time.RFC3339 - - // TimestampFunc defines the function called to generate a timestamp. - TimestampFunc = time.Now - - // DurationFieldUnit defines the unit for time.Duration type fields added - // using the Dur method. - DurationFieldUnit = time.Millisecond - - // DurationFieldInteger renders Dur fields as integer instead of float if - // set to true. - DurationFieldInteger = false - - // ErrorHandler is called whenever zerolog fails to write an event on its - // output. If not set, an error is printed on the stderr. This handler must - // be thread safe and non-blocking. - ErrorHandler func(err error) - - // DefaultContextLogger is returned from Ctx() if there is no logger associated - // with the context. - DefaultContextLogger *Logger -) - -var ( - gLevel = new(int32) - disableSampling = new(int32) -) - -// SetGlobalLevel sets the global override for log level. If this -// values is raised, all Loggers will use at least this value. -// -// To globally disable logs, set GlobalLevel to Disabled. -func SetGlobalLevel(l Level) { - atomic.StoreInt32(gLevel, int32(l)) -} - -// GlobalLevel returns the current global log level -func GlobalLevel() Level { - return Level(atomic.LoadInt32(gLevel)) -} - -// DisableSampling will disable sampling in all Loggers if true. -func DisableSampling(v bool) { - var i int32 - if v { - i = 1 - } - atomic.StoreInt32(disableSampling, i) -} - -func samplingDisabled() bool { - return atomic.LoadInt32(disableSampling) == 1 -} diff --git a/vendor/github.com/rs/zerolog/go112.go b/vendor/github.com/rs/zerolog/go112.go deleted file mode 100644 index e7b5a1bd..00000000 --- a/vendor/github.com/rs/zerolog/go112.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build go1.12 - -package zerolog - -// Since go 1.12, some auto generated init functions are hidden from -// runtime.Caller. -const contextCallerSkipFrameCount = 2 diff --git a/vendor/github.com/rs/zerolog/hook.go b/vendor/github.com/rs/zerolog/hook.go deleted file mode 100644 index ec6effc1..00000000 --- a/vendor/github.com/rs/zerolog/hook.go +++ /dev/null @@ -1,64 +0,0 @@ -package zerolog - -// Hook defines an interface to a log hook. -type Hook interface { - // Run runs the hook with the event. - Run(e *Event, level Level, message string) -} - -// HookFunc is an adaptor to allow the use of an ordinary function -// as a Hook. -type HookFunc func(e *Event, level Level, message string) - -// Run implements the Hook interface. -func (h HookFunc) Run(e *Event, level Level, message string) { - h(e, level, message) -} - -// LevelHook applies a different hook for each level. -type LevelHook struct { - NoLevelHook, TraceHook, DebugHook, InfoHook, WarnHook, ErrorHook, FatalHook, PanicHook Hook -} - -// Run implements the Hook interface. -func (h LevelHook) Run(e *Event, level Level, message string) { - switch level { - case TraceLevel: - if h.TraceHook != nil { - h.TraceHook.Run(e, level, message) - } - case DebugLevel: - if h.DebugHook != nil { - h.DebugHook.Run(e, level, message) - } - case InfoLevel: - if h.InfoHook != nil { - h.InfoHook.Run(e, level, message) - } - case WarnLevel: - if h.WarnHook != nil { - h.WarnHook.Run(e, level, message) - } - case ErrorLevel: - if h.ErrorHook != nil { - h.ErrorHook.Run(e, level, message) - } - case FatalLevel: - if h.FatalHook != nil { - h.FatalHook.Run(e, level, message) - } - case PanicLevel: - if h.PanicHook != nil { - h.PanicHook.Run(e, level, message) - } - case NoLevel: - if h.NoLevelHook != nil { - h.NoLevelHook.Run(e, level, message) - } - } -} - -// NewLevelHook returns a new LevelHook. -func NewLevelHook() LevelHook { - return LevelHook{} -} diff --git a/vendor/github.com/rs/zerolog/internal/cbor/README.md b/vendor/github.com/rs/zerolog/internal/cbor/README.md deleted file mode 100644 index 92c2e8c7..00000000 --- a/vendor/github.com/rs/zerolog/internal/cbor/README.md +++ /dev/null @@ -1,56 +0,0 @@ -## Reference: - CBOR Encoding is described in [RFC7049](https://tools.ietf.org/html/rfc7049) - -## Comparison of JSON vs CBOR - -Two main areas of reduction are: - -1. CPU usage to write a log msg -2. Size (in bytes) of log messages. - - -CPU Usage savings are below: -``` -name JSON time/op CBOR time/op delta -Info-32 15.3ns ± 1% 11.7ns ± 3% -23.78% (p=0.000 n=9+10) -ContextFields-32 16.2ns ± 2% 12.3ns ± 3% -23.97% (p=0.000 n=9+9) -ContextAppend-32 6.70ns ± 0% 6.20ns ± 0% -7.44% (p=0.000 n=9+9) -LogFields-32 66.4ns ± 0% 24.6ns ± 2% -62.89% (p=0.000 n=10+9) -LogArrayObject-32 911ns ±11% 768ns ± 6% -15.64% (p=0.000 n=10+10) -LogFieldType/Floats-32 70.3ns ± 2% 29.5ns ± 1% -57.98% (p=0.000 n=10+10) -LogFieldType/Err-32 14.0ns ± 3% 12.1ns ± 8% -13.20% (p=0.000 n=8+10) -LogFieldType/Dur-32 17.2ns ± 2% 13.1ns ± 1% -24.27% (p=0.000 n=10+9) -LogFieldType/Object-32 54.3ns ±11% 52.3ns ± 7% ~ (p=0.239 n=10+10) -LogFieldType/Ints-32 20.3ns ± 2% 15.1ns ± 2% -25.50% (p=0.000 n=9+10) -LogFieldType/Interfaces-32 642ns ±11% 621ns ± 9% ~ (p=0.118 n=10+10) -LogFieldType/Interface(Objects)-32 635ns ±13% 632ns ± 9% ~ (p=0.592 n=10+10) -LogFieldType/Times-32 294ns ± 0% 27ns ± 1% -90.71% (p=0.000 n=10+9) -LogFieldType/Durs-32 121ns ± 0% 33ns ± 2% -72.44% (p=0.000 n=9+9) -LogFieldType/Interface(Object)-32 56.6ns ± 8% 52.3ns ± 8% -7.54% (p=0.007 n=10+10) -LogFieldType/Errs-32 17.8ns ± 3% 16.1ns ± 2% -9.71% (p=0.000 n=10+9) -LogFieldType/Time-32 40.5ns ± 1% 12.7ns ± 6% -68.66% (p=0.000 n=8+9) -LogFieldType/Bool-32 12.0ns ± 5% 10.2ns ± 2% -15.18% (p=0.000 n=10+8) -LogFieldType/Bools-32 17.2ns ± 2% 12.6ns ± 4% -26.63% (p=0.000 n=10+10) -LogFieldType/Int-32 12.3ns ± 2% 11.2ns ± 4% -9.27% (p=0.000 n=9+10) -LogFieldType/Float-32 16.7ns ± 1% 12.6ns ± 2% -24.42% (p=0.000 n=7+9) -LogFieldType/Str-32 12.7ns ± 7% 11.3ns ± 7% -10.88% (p=0.000 n=10+9) -LogFieldType/Strs-32 20.3ns ± 3% 18.2ns ± 3% -10.25% (p=0.000 n=9+10) -LogFieldType/Interface-32 183ns ±12% 175ns ± 9% ~ (p=0.078 n=10+10) -``` - -Log message size savings is greatly dependent on the number and type of fields in the log message. -Assuming this log message (with an Integer, timestamp and string, in addition to level). - -`{"level":"error","Fault":41650,"time":"2018-04-01T15:18:19-07:00","message":"Some Message"}` - -Two measurements were done for the log file sizes - one without any compression, second -using [compress/zlib](https://golang.org/pkg/compress/zlib/). - -Results for 10,000 log messages: - -| Log Format | Plain File Size (in KB) | Compressed File Size (in KB) | -| :--- | :---: | :---: | -| JSON | 920 | 28 | -| CBOR | 550 | 28 | - -The example used to calculate the above data is available in [Examples](examples). diff --git a/vendor/github.com/rs/zerolog/internal/cbor/base.go b/vendor/github.com/rs/zerolog/internal/cbor/base.go deleted file mode 100644 index 51fe86c9..00000000 --- a/vendor/github.com/rs/zerolog/internal/cbor/base.go +++ /dev/null @@ -1,19 +0,0 @@ -package cbor - -// JSONMarshalFunc is used to marshal interface to JSON encoded byte slice. -// Making it package level instead of embedded in Encoder brings -// some extra efforts at importing, but avoids value copy when the functions -// of Encoder being invoked. -// DO REMEMBER to set this variable at importing, or -// you might get a nil pointer dereference panic at runtime. -var JSONMarshalFunc func(v interface{}) ([]byte, error) - -type Encoder struct{} - -// AppendKey adds a key (string) to the binary encoded log message -func (e Encoder) AppendKey(dst []byte, key string) []byte { - if len(dst) < 1 { - dst = e.AppendBeginMarker(dst) - } - return e.AppendString(dst, key) -} diff --git a/vendor/github.com/rs/zerolog/internal/cbor/cbor.go b/vendor/github.com/rs/zerolog/internal/cbor/cbor.go deleted file mode 100644 index bc54e37a..00000000 --- a/vendor/github.com/rs/zerolog/internal/cbor/cbor.go +++ /dev/null @@ -1,101 +0,0 @@ -// Package cbor provides primitives for storing different data -// in the CBOR (binary) format. CBOR is defined in RFC7049. -package cbor - -import "time" - -const ( - majorOffset = 5 - additionalMax = 23 - - // Non Values. - additionalTypeBoolFalse byte = 20 - additionalTypeBoolTrue byte = 21 - additionalTypeNull byte = 22 - - // Integer (+ve and -ve) Sub-types. - additionalTypeIntUint8 byte = 24 - additionalTypeIntUint16 byte = 25 - additionalTypeIntUint32 byte = 26 - additionalTypeIntUint64 byte = 27 - - // Float Sub-types. - additionalTypeFloat16 byte = 25 - additionalTypeFloat32 byte = 26 - additionalTypeFloat64 byte = 27 - additionalTypeBreak byte = 31 - - // Tag Sub-types. - additionalTypeTimestamp byte = 01 - - // Extended Tags - from https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml - additionalTypeTagNetworkAddr uint16 = 260 - additionalTypeTagNetworkPrefix uint16 = 261 - additionalTypeEmbeddedJSON uint16 = 262 - additionalTypeTagHexString uint16 = 263 - - // Unspecified number of elements. - additionalTypeInfiniteCount byte = 31 -) -const ( - majorTypeUnsignedInt byte = iota << majorOffset // Major type 0 - majorTypeNegativeInt // Major type 1 - majorTypeByteString // Major type 2 - majorTypeUtf8String // Major type 3 - majorTypeArray // Major type 4 - majorTypeMap // Major type 5 - majorTypeTags // Major type 6 - majorTypeSimpleAndFloat // Major type 7 -) - -const ( - maskOutAdditionalType byte = (7 << majorOffset) - maskOutMajorType byte = 31 -) - -const ( - float32Nan = "\xfa\x7f\xc0\x00\x00" - float32PosInfinity = "\xfa\x7f\x80\x00\x00" - float32NegInfinity = "\xfa\xff\x80\x00\x00" - float64Nan = "\xfb\x7f\xf8\x00\x00\x00\x00\x00\x00" - float64PosInfinity = "\xfb\x7f\xf0\x00\x00\x00\x00\x00\x00" - float64NegInfinity = "\xfb\xff\xf0\x00\x00\x00\x00\x00\x00" -) - -// IntegerTimeFieldFormat indicates the format of timestamp decoded -// from an integer (time in seconds). -var IntegerTimeFieldFormat = time.RFC3339 - -// NanoTimeFieldFormat indicates the format of timestamp decoded -// from a float value (time in seconds and nanoseconds). -var NanoTimeFieldFormat = time.RFC3339Nano - -func appendCborTypePrefix(dst []byte, major byte, number uint64) []byte { - byteCount := 8 - var minor byte - switch { - case number < 256: - byteCount = 1 - minor = additionalTypeIntUint8 - - case number < 65536: - byteCount = 2 - minor = additionalTypeIntUint16 - - case number < 4294967296: - byteCount = 4 - minor = additionalTypeIntUint32 - - default: - byteCount = 8 - minor = additionalTypeIntUint64 - - } - - dst = append(dst, major|minor) - byteCount-- - for ; byteCount >= 0; byteCount-- { - dst = append(dst, byte(number>>(uint(byteCount)*8))) - } - return dst -} diff --git a/vendor/github.com/rs/zerolog/internal/cbor/decode_stream.go b/vendor/github.com/rs/zerolog/internal/cbor/decode_stream.go deleted file mode 100644 index fc16f98c..00000000 --- a/vendor/github.com/rs/zerolog/internal/cbor/decode_stream.go +++ /dev/null @@ -1,614 +0,0 @@ -package cbor - -// This file contains code to decode a stream of CBOR Data into JSON. - -import ( - "bufio" - "bytes" - "fmt" - "io" - "math" - "net" - "runtime" - "strconv" - "strings" - "time" - "unicode/utf8" -) - -var decodeTimeZone *time.Location - -const hexTable = "0123456789abcdef" - -const isFloat32 = 4 -const isFloat64 = 8 - -func readNBytes(src *bufio.Reader, n int) []byte { - ret := make([]byte, n) - for i := 0; i < n; i++ { - ch, e := src.ReadByte() - if e != nil { - panic(fmt.Errorf("Tried to Read %d Bytes.. But hit end of file", n)) - } - ret[i] = ch - } - return ret -} - -func readByte(src *bufio.Reader) byte { - b, e := src.ReadByte() - if e != nil { - panic(fmt.Errorf("Tried to Read 1 Byte.. But hit end of file")) - } - return b -} - -func decodeIntAdditionalType(src *bufio.Reader, minor byte) int64 { - val := int64(0) - if minor <= 23 { - val = int64(minor) - } else { - bytesToRead := 0 - switch minor { - case additionalTypeIntUint8: - bytesToRead = 1 - case additionalTypeIntUint16: - bytesToRead = 2 - case additionalTypeIntUint32: - bytesToRead = 4 - case additionalTypeIntUint64: - bytesToRead = 8 - default: - panic(fmt.Errorf("Invalid Additional Type: %d in decodeInteger (expected <28)", minor)) - } - pb := readNBytes(src, bytesToRead) - for i := 0; i < bytesToRead; i++ { - val = val * 256 - val += int64(pb[i]) - } - } - return val -} - -func decodeInteger(src *bufio.Reader) int64 { - pb := readByte(src) - major := pb & maskOutAdditionalType - minor := pb & maskOutMajorType - if major != majorTypeUnsignedInt && major != majorTypeNegativeInt { - panic(fmt.Errorf("Major type is: %d in decodeInteger!! (expected 0 or 1)", major)) - } - val := decodeIntAdditionalType(src, minor) - if major == 0 { - return val - } - return (-1 - val) -} - -func decodeFloat(src *bufio.Reader) (float64, int) { - pb := readByte(src) - major := pb & maskOutAdditionalType - minor := pb & maskOutMajorType - if major != majorTypeSimpleAndFloat { - panic(fmt.Errorf("Incorrect Major type is: %d in decodeFloat", major)) - } - - switch minor { - case additionalTypeFloat16: - panic(fmt.Errorf("float16 is not suppported in decodeFloat")) - - case additionalTypeFloat32: - pb := readNBytes(src, 4) - switch string(pb) { - case float32Nan: - return math.NaN(), isFloat32 - case float32PosInfinity: - return math.Inf(0), isFloat32 - case float32NegInfinity: - return math.Inf(-1), isFloat32 - } - n := uint32(0) - for i := 0; i < 4; i++ { - n = n * 256 - n += uint32(pb[i]) - } - val := math.Float32frombits(n) - return float64(val), isFloat32 - case additionalTypeFloat64: - pb := readNBytes(src, 8) - switch string(pb) { - case float64Nan: - return math.NaN(), isFloat64 - case float64PosInfinity: - return math.Inf(0), isFloat64 - case float64NegInfinity: - return math.Inf(-1), isFloat64 - } - n := uint64(0) - for i := 0; i < 8; i++ { - n = n * 256 - n += uint64(pb[i]) - } - val := math.Float64frombits(n) - return val, isFloat64 - } - panic(fmt.Errorf("Invalid Additional Type: %d in decodeFloat", minor)) -} - -func decodeStringComplex(dst []byte, s string, pos uint) []byte { - i := int(pos) - start := 0 - - for i < len(s) { - b := s[i] - if b >= utf8.RuneSelf { - r, size := utf8.DecodeRuneInString(s[i:]) - if r == utf8.RuneError && size == 1 { - // In case of error, first append previous simple characters to - // the byte slice if any and append a replacement character code - // in place of the invalid sequence. - if start < i { - dst = append(dst, s[start:i]...) - } - dst = append(dst, `\ufffd`...) - i += size - start = i - continue - } - i += size - continue - } - if b >= 0x20 && b <= 0x7e && b != '\\' && b != '"' { - i++ - continue - } - // We encountered a character that needs to be encoded. - // Let's append the previous simple characters to the byte slice - // and switch our operation to read and encode the remainder - // characters byte-by-byte. - if start < i { - dst = append(dst, s[start:i]...) - } - switch b { - case '"', '\\': - dst = append(dst, '\\', b) - case '\b': - dst = append(dst, '\\', 'b') - case '\f': - dst = append(dst, '\\', 'f') - case '\n': - dst = append(dst, '\\', 'n') - case '\r': - dst = append(dst, '\\', 'r') - case '\t': - dst = append(dst, '\\', 't') - default: - dst = append(dst, '\\', 'u', '0', '0', hexTable[b>>4], hexTable[b&0xF]) - } - i++ - start = i - } - if start < len(s) { - dst = append(dst, s[start:]...) - } - return dst -} - -func decodeString(src *bufio.Reader, noQuotes bool) []byte { - pb := readByte(src) - major := pb & maskOutAdditionalType - minor := pb & maskOutMajorType - if major != majorTypeByteString { - panic(fmt.Errorf("Major type is: %d in decodeString", major)) - } - result := []byte{} - if !noQuotes { - result = append(result, '"') - } - length := decodeIntAdditionalType(src, minor) - len := int(length) - pbs := readNBytes(src, len) - result = append(result, pbs...) - if noQuotes { - return result - } - return append(result, '"') -} - -func decodeUTF8String(src *bufio.Reader) []byte { - pb := readByte(src) - major := pb & maskOutAdditionalType - minor := pb & maskOutMajorType - if major != majorTypeUtf8String { - panic(fmt.Errorf("Major type is: %d in decodeUTF8String", major)) - } - result := []byte{'"'} - length := decodeIntAdditionalType(src, minor) - len := int(length) - pbs := readNBytes(src, len) - - for i := 0; i < len; i++ { - // Check if the character needs encoding. Control characters, slashes, - // and the double quote need json encoding. Bytes above the ascii - // boundary needs utf8 encoding. - if pbs[i] < 0x20 || pbs[i] > 0x7e || pbs[i] == '\\' || pbs[i] == '"' { - // We encountered a character that needs to be encoded. Switch - // to complex version of the algorithm. - dst := []byte{'"'} - dst = decodeStringComplex(dst, string(pbs), uint(i)) - return append(dst, '"') - } - } - // The string has no need for encoding and therefore is directly - // appended to the byte slice. - result = append(result, pbs...) - return append(result, '"') -} - -func array2Json(src *bufio.Reader, dst io.Writer) { - dst.Write([]byte{'['}) - pb := readByte(src) - major := pb & maskOutAdditionalType - minor := pb & maskOutMajorType - if major != majorTypeArray { - panic(fmt.Errorf("Major type is: %d in array2Json", major)) - } - len := 0 - unSpecifiedCount := false - if minor == additionalTypeInfiniteCount { - unSpecifiedCount = true - } else { - length := decodeIntAdditionalType(src, minor) - len = int(length) - } - for i := 0; unSpecifiedCount || i < len; i++ { - if unSpecifiedCount { - pb, e := src.Peek(1) - if e != nil { - panic(e) - } - if pb[0] == majorTypeSimpleAndFloat|additionalTypeBreak { - readByte(src) - break - } - } - cbor2JsonOneObject(src, dst) - if unSpecifiedCount { - pb, e := src.Peek(1) - if e != nil { - panic(e) - } - if pb[0] == majorTypeSimpleAndFloat|additionalTypeBreak { - readByte(src) - break - } - dst.Write([]byte{','}) - } else if i+1 < len { - dst.Write([]byte{','}) - } - } - dst.Write([]byte{']'}) -} - -func map2Json(src *bufio.Reader, dst io.Writer) { - pb := readByte(src) - major := pb & maskOutAdditionalType - minor := pb & maskOutMajorType - if major != majorTypeMap { - panic(fmt.Errorf("Major type is: %d in map2Json", major)) - } - len := 0 - unSpecifiedCount := false - if minor == additionalTypeInfiniteCount { - unSpecifiedCount = true - } else { - length := decodeIntAdditionalType(src, minor) - len = int(length) - } - dst.Write([]byte{'{'}) - for i := 0; unSpecifiedCount || i < len; i++ { - if unSpecifiedCount { - pb, e := src.Peek(1) - if e != nil { - panic(e) - } - if pb[0] == majorTypeSimpleAndFloat|additionalTypeBreak { - readByte(src) - break - } - } - cbor2JsonOneObject(src, dst) - if i%2 == 0 { - // Even position values are keys. - dst.Write([]byte{':'}) - } else { - if unSpecifiedCount { - pb, e := src.Peek(1) - if e != nil { - panic(e) - } - if pb[0] == majorTypeSimpleAndFloat|additionalTypeBreak { - readByte(src) - break - } - dst.Write([]byte{','}) - } else if i+1 < len { - dst.Write([]byte{','}) - } - } - } - dst.Write([]byte{'}'}) -} - -func decodeTagData(src *bufio.Reader) []byte { - pb := readByte(src) - major := pb & maskOutAdditionalType - minor := pb & maskOutMajorType - if major != majorTypeTags { - panic(fmt.Errorf("Major type is: %d in decodeTagData", major)) - } - switch minor { - case additionalTypeTimestamp: - return decodeTimeStamp(src) - - // Tag value is larger than 256 (so uint16). - case additionalTypeIntUint16: - val := decodeIntAdditionalType(src, minor) - - switch uint16(val) { - case additionalTypeEmbeddedJSON: - pb := readByte(src) - dataMajor := pb & maskOutAdditionalType - if dataMajor != majorTypeByteString { - panic(fmt.Errorf("Unsupported embedded Type: %d in decodeEmbeddedJSON", dataMajor)) - } - src.UnreadByte() - return decodeString(src, true) - - case additionalTypeTagNetworkAddr: - octets := decodeString(src, true) - ss := []byte{'"'} - switch len(octets) { - case 6: // MAC address. - ha := net.HardwareAddr(octets) - ss = append(append(ss, ha.String()...), '"') - case 4: // IPv4 address. - fallthrough - case 16: // IPv6 address. - ip := net.IP(octets) - ss = append(append(ss, ip.String()...), '"') - default: - panic(fmt.Errorf("Unexpected Network Address length: %d (expected 4,6,16)", len(octets))) - } - return ss - - case additionalTypeTagNetworkPrefix: - pb := readByte(src) - if pb != majorTypeMap|0x1 { - panic(fmt.Errorf("IP Prefix is NOT of MAP of 1 elements as expected")) - } - octets := decodeString(src, true) - val := decodeInteger(src) - ip := net.IP(octets) - var mask net.IPMask - pfxLen := int(val) - if len(octets) == 4 { - mask = net.CIDRMask(pfxLen, 32) - } else { - mask = net.CIDRMask(pfxLen, 128) - } - ipPfx := net.IPNet{IP: ip, Mask: mask} - ss := []byte{'"'} - ss = append(append(ss, ipPfx.String()...), '"') - return ss - - case additionalTypeTagHexString: - octets := decodeString(src, true) - ss := []byte{'"'} - for _, v := range octets { - ss = append(ss, hexTable[v>>4], hexTable[v&0x0f]) - } - return append(ss, '"') - - default: - panic(fmt.Errorf("Unsupported Additional Tag Type: %d in decodeTagData", val)) - } - } - panic(fmt.Errorf("Unsupported Additional Type: %d in decodeTagData", minor)) -} - -func decodeTimeStamp(src *bufio.Reader) []byte { - pb := readByte(src) - src.UnreadByte() - tsMajor := pb & maskOutAdditionalType - if tsMajor == majorTypeUnsignedInt || tsMajor == majorTypeNegativeInt { - n := decodeInteger(src) - t := time.Unix(n, 0) - if decodeTimeZone != nil { - t = t.In(decodeTimeZone) - } else { - t = t.In(time.UTC) - } - tsb := []byte{} - tsb = append(tsb, '"') - tsb = t.AppendFormat(tsb, IntegerTimeFieldFormat) - tsb = append(tsb, '"') - return tsb - } else if tsMajor == majorTypeSimpleAndFloat { - n, _ := decodeFloat(src) - secs := int64(n) - n -= float64(secs) - n *= float64(1e9) - t := time.Unix(secs, int64(n)) - if decodeTimeZone != nil { - t = t.In(decodeTimeZone) - } else { - t = t.In(time.UTC) - } - tsb := []byte{} - tsb = append(tsb, '"') - tsb = t.AppendFormat(tsb, NanoTimeFieldFormat) - tsb = append(tsb, '"') - return tsb - } - panic(fmt.Errorf("TS format is neigther int nor float: %d", tsMajor)) -} - -func decodeSimpleFloat(src *bufio.Reader) []byte { - pb := readByte(src) - major := pb & maskOutAdditionalType - minor := pb & maskOutMajorType - if major != majorTypeSimpleAndFloat { - panic(fmt.Errorf("Major type is: %d in decodeSimpleFloat", major)) - } - switch minor { - case additionalTypeBoolTrue: - return []byte("true") - case additionalTypeBoolFalse: - return []byte("false") - case additionalTypeNull: - return []byte("null") - case additionalTypeFloat16: - fallthrough - case additionalTypeFloat32: - fallthrough - case additionalTypeFloat64: - src.UnreadByte() - v, bc := decodeFloat(src) - ba := []byte{} - switch { - case math.IsNaN(v): - return []byte("\"NaN\"") - case math.IsInf(v, 1): - return []byte("\"+Inf\"") - case math.IsInf(v, -1): - return []byte("\"-Inf\"") - } - if bc == isFloat32 { - ba = strconv.AppendFloat(ba, v, 'f', -1, 32) - } else if bc == isFloat64 { - ba = strconv.AppendFloat(ba, v, 'f', -1, 64) - } else { - panic(fmt.Errorf("Invalid Float precision from decodeFloat: %d", bc)) - } - return ba - default: - panic(fmt.Errorf("Invalid Additional Type: %d in decodeSimpleFloat", minor)) - } -} - -func cbor2JsonOneObject(src *bufio.Reader, dst io.Writer) { - pb, e := src.Peek(1) - if e != nil { - panic(e) - } - major := (pb[0] & maskOutAdditionalType) - - switch major { - case majorTypeUnsignedInt: - fallthrough - case majorTypeNegativeInt: - n := decodeInteger(src) - dst.Write([]byte(strconv.Itoa(int(n)))) - - case majorTypeByteString: - s := decodeString(src, false) - dst.Write(s) - - case majorTypeUtf8String: - s := decodeUTF8String(src) - dst.Write(s) - - case majorTypeArray: - array2Json(src, dst) - - case majorTypeMap: - map2Json(src, dst) - - case majorTypeTags: - s := decodeTagData(src) - dst.Write(s) - - case majorTypeSimpleAndFloat: - s := decodeSimpleFloat(src) - dst.Write(s) - } -} - -func moreBytesToRead(src *bufio.Reader) bool { - _, e := src.ReadByte() - if e == nil { - src.UnreadByte() - return true - } - return false -} - -// Cbor2JsonManyObjects decodes all the CBOR Objects read from src -// reader. It keeps on decoding until reader returns EOF (error when reading). -// Decoded string is written to the dst. At the end of every CBOR Object -// newline is written to the output stream. -// -// Returns error (if any) that was encountered during decode. -// The child functions will generate a panic when error is encountered and -// this function will recover non-runtime Errors and return the reason as error. -func Cbor2JsonManyObjects(src io.Reader, dst io.Writer) (err error) { - defer func() { - if r := recover(); r != nil { - if _, ok := r.(runtime.Error); ok { - panic(r) - } - err = r.(error) - } - }() - bufRdr := bufio.NewReader(src) - for moreBytesToRead(bufRdr) { - cbor2JsonOneObject(bufRdr, dst) - dst.Write([]byte("\n")) - } - return nil -} - -// Detect if the bytes to be printed is Binary or not. -func binaryFmt(p []byte) bool { - if len(p) > 0 && p[0] > 0x7F { - return true - } - return false -} - -func getReader(str string) *bufio.Reader { - return bufio.NewReader(strings.NewReader(str)) -} - -// DecodeIfBinaryToString converts a binary formatted log msg to a -// JSON formatted String Log message - suitable for printing to Console/Syslog. -func DecodeIfBinaryToString(in []byte) string { - if binaryFmt(in) { - var b bytes.Buffer - Cbor2JsonManyObjects(strings.NewReader(string(in)), &b) - return b.String() - } - return string(in) -} - -// DecodeObjectToStr checks if the input is a binary format, if so, -// it will decode a single Object and return the decoded string. -func DecodeObjectToStr(in []byte) string { - if binaryFmt(in) { - var b bytes.Buffer - cbor2JsonOneObject(getReader(string(in)), &b) - return b.String() - } - return string(in) -} - -// DecodeIfBinaryToBytes checks if the input is a binary format, if so, -// it will decode all Objects and return the decoded string as byte array. -func DecodeIfBinaryToBytes(in []byte) []byte { - if binaryFmt(in) { - var b bytes.Buffer - Cbor2JsonManyObjects(bytes.NewReader(in), &b) - return b.Bytes() - } - return in -} diff --git a/vendor/github.com/rs/zerolog/internal/cbor/string.go b/vendor/github.com/rs/zerolog/internal/cbor/string.go deleted file mode 100644 index a33890a5..00000000 --- a/vendor/github.com/rs/zerolog/internal/cbor/string.go +++ /dev/null @@ -1,95 +0,0 @@ -package cbor - -import "fmt" - -// AppendStrings encodes and adds an array of strings to the dst byte array. -func (e Encoder) AppendStrings(dst []byte, vals []string) []byte { - major := majorTypeArray - l := len(vals) - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendString(dst, v) - } - return dst -} - -// AppendString encodes and adds a string to the dst byte array. -func (Encoder) AppendString(dst []byte, s string) []byte { - major := majorTypeUtf8String - - l := len(s) - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, majorTypeUtf8String, uint64(l)) - } - return append(dst, s...) -} - -// AppendStringers encodes and adds an array of Stringer values -// to the dst byte array. -func (e Encoder) AppendStringers(dst []byte, vals []fmt.Stringer) []byte { - if len(vals) == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - dst = e.AppendArrayStart(dst) - dst = e.AppendStringer(dst, vals[0]) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = e.AppendStringer(dst, val) - } - } - return e.AppendArrayEnd(dst) -} - -// AppendStringer encodes and adds the Stringer value to the dst -// byte array. -func (e Encoder) AppendStringer(dst []byte, val fmt.Stringer) []byte { - if val == nil { - return e.AppendNil(dst) - } - return e.AppendString(dst, val.String()) -} - -// AppendBytes encodes and adds an array of bytes to the dst byte array. -func (Encoder) AppendBytes(dst, s []byte) []byte { - major := majorTypeByteString - - l := len(s) - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - return append(dst, s...) -} - -// AppendEmbeddedJSON adds a tag and embeds input JSON as such. -func AppendEmbeddedJSON(dst, s []byte) []byte { - major := majorTypeTags - minor := additionalTypeEmbeddedJSON - - // Append the TAG to indicate this is Embedded JSON. - dst = append(dst, major|additionalTypeIntUint16) - dst = append(dst, byte(minor>>8)) - dst = append(dst, byte(minor&0xff)) - - // Append the JSON Object as Byte String. - major = majorTypeByteString - - l := len(s) - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - return append(dst, s...) -} diff --git a/vendor/github.com/rs/zerolog/internal/cbor/time.go b/vendor/github.com/rs/zerolog/internal/cbor/time.go deleted file mode 100644 index d81fb125..00000000 --- a/vendor/github.com/rs/zerolog/internal/cbor/time.go +++ /dev/null @@ -1,93 +0,0 @@ -package cbor - -import ( - "time" -) - -func appendIntegerTimestamp(dst []byte, t time.Time) []byte { - major := majorTypeTags - minor := additionalTypeTimestamp - dst = append(dst, major|minor) - secs := t.Unix() - var val uint64 - if secs < 0 { - major = majorTypeNegativeInt - val = uint64(-secs - 1) - } else { - major = majorTypeUnsignedInt - val = uint64(secs) - } - dst = appendCborTypePrefix(dst, major, val) - return dst -} - -func (e Encoder) appendFloatTimestamp(dst []byte, t time.Time) []byte { - major := majorTypeTags - minor := additionalTypeTimestamp - dst = append(dst, major|minor) - secs := t.Unix() - nanos := t.Nanosecond() - var val float64 - val = float64(secs)*1.0 + float64(nanos)*1e-9 - return e.AppendFloat64(dst, val) -} - -// AppendTime encodes and adds a timestamp to the dst byte array. -func (e Encoder) AppendTime(dst []byte, t time.Time, unused string) []byte { - utc := t.UTC() - if utc.Nanosecond() == 0 { - return appendIntegerTimestamp(dst, utc) - } - return e.appendFloatTimestamp(dst, utc) -} - -// AppendTimes encodes and adds an array of timestamps to the dst byte array. -func (e Encoder) AppendTimes(dst []byte, vals []time.Time, unused string) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - - for _, t := range vals { - dst = e.AppendTime(dst, t, unused) - } - return dst -} - -// AppendDuration encodes and adds a duration to the dst byte array. -// useInt field indicates whether to store the duration as seconds (integer) or -// as seconds+nanoseconds (float). -func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte { - if useInt { - return e.AppendInt64(dst, int64(d/unit)) - } - return e.AppendFloat64(dst, float64(d)/float64(unit)) -} - -// AppendDurations encodes and adds an array of durations to the dst byte array. -// useInt field indicates whether to store the duration as seconds (integer) or -// as seconds+nanoseconds (float). -func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, d := range vals { - dst = e.AppendDuration(dst, d, unit, useInt) - } - return dst -} diff --git a/vendor/github.com/rs/zerolog/internal/cbor/types.go b/vendor/github.com/rs/zerolog/internal/cbor/types.go deleted file mode 100644 index 49316aa5..00000000 --- a/vendor/github.com/rs/zerolog/internal/cbor/types.go +++ /dev/null @@ -1,477 +0,0 @@ -package cbor - -import ( - "fmt" - "math" - "net" -) - -// AppendNil inserts a 'Nil' object into the dst byte array. -func (Encoder) AppendNil(dst []byte) []byte { - return append(dst, majorTypeSimpleAndFloat|additionalTypeNull) -} - -// AppendBeginMarker inserts a map start into the dst byte array. -func (Encoder) AppendBeginMarker(dst []byte) []byte { - return append(dst, majorTypeMap|additionalTypeInfiniteCount) -} - -// AppendEndMarker inserts a map end into the dst byte array. -func (Encoder) AppendEndMarker(dst []byte) []byte { - return append(dst, majorTypeSimpleAndFloat|additionalTypeBreak) -} - -// AppendObjectData takes an object in form of a byte array and appends to dst. -func (Encoder) AppendObjectData(dst []byte, o []byte) []byte { - // BeginMarker is present in the dst, which - // should not be copied when appending to existing data. - return append(dst, o[1:]...) -} - -// AppendArrayStart adds markers to indicate the start of an array. -func (Encoder) AppendArrayStart(dst []byte) []byte { - return append(dst, majorTypeArray|additionalTypeInfiniteCount) -} - -// AppendArrayEnd adds markers to indicate the end of an array. -func (Encoder) AppendArrayEnd(dst []byte) []byte { - return append(dst, majorTypeSimpleAndFloat|additionalTypeBreak) -} - -// AppendArrayDelim adds markers to indicate end of a particular array element. -func (Encoder) AppendArrayDelim(dst []byte) []byte { - //No delimiters needed in cbor - return dst -} - -// AppendLineBreak is a noop that keep API compat with json encoder. -func (Encoder) AppendLineBreak(dst []byte) []byte { - // No line breaks needed in binary format. - return dst -} - -// AppendBool encodes and inserts a boolean value into the dst byte array. -func (Encoder) AppendBool(dst []byte, val bool) []byte { - b := additionalTypeBoolFalse - if val { - b = additionalTypeBoolTrue - } - return append(dst, majorTypeSimpleAndFloat|b) -} - -// AppendBools encodes and inserts an array of boolean values into the dst byte array. -func (e Encoder) AppendBools(dst []byte, vals []bool) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendBool(dst, v) - } - return dst -} - -// AppendInt encodes and inserts an integer value into the dst byte array. -func (Encoder) AppendInt(dst []byte, val int) []byte { - major := majorTypeUnsignedInt - contentVal := val - if val < 0 { - major = majorTypeNegativeInt - contentVal = -val - 1 - } - if contentVal <= additionalMax { - lb := byte(contentVal) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(contentVal)) - } - return dst -} - -// AppendInts encodes and inserts an array of integer values into the dst byte array. -func (e Encoder) AppendInts(dst []byte, vals []int) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendInt(dst, v) - } - return dst -} - -// AppendInt8 encodes and inserts an int8 value into the dst byte array. -func (e Encoder) AppendInt8(dst []byte, val int8) []byte { - return e.AppendInt(dst, int(val)) -} - -// AppendInts8 encodes and inserts an array of integer values into the dst byte array. -func (e Encoder) AppendInts8(dst []byte, vals []int8) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendInt(dst, int(v)) - } - return dst -} - -// AppendInt16 encodes and inserts a int16 value into the dst byte array. -func (e Encoder) AppendInt16(dst []byte, val int16) []byte { - return e.AppendInt(dst, int(val)) -} - -// AppendInts16 encodes and inserts an array of int16 values into the dst byte array. -func (e Encoder) AppendInts16(dst []byte, vals []int16) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendInt(dst, int(v)) - } - return dst -} - -// AppendInt32 encodes and inserts a int32 value into the dst byte array. -func (e Encoder) AppendInt32(dst []byte, val int32) []byte { - return e.AppendInt(dst, int(val)) -} - -// AppendInts32 encodes and inserts an array of int32 values into the dst byte array. -func (e Encoder) AppendInts32(dst []byte, vals []int32) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendInt(dst, int(v)) - } - return dst -} - -// AppendInt64 encodes and inserts a int64 value into the dst byte array. -func (Encoder) AppendInt64(dst []byte, val int64) []byte { - major := majorTypeUnsignedInt - contentVal := val - if val < 0 { - major = majorTypeNegativeInt - contentVal = -val - 1 - } - if contentVal <= additionalMax { - lb := byte(contentVal) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(contentVal)) - } - return dst -} - -// AppendInts64 encodes and inserts an array of int64 values into the dst byte array. -func (e Encoder) AppendInts64(dst []byte, vals []int64) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendInt64(dst, v) - } - return dst -} - -// AppendUint encodes and inserts an unsigned integer value into the dst byte array. -func (e Encoder) AppendUint(dst []byte, val uint) []byte { - return e.AppendInt64(dst, int64(val)) -} - -// AppendUints encodes and inserts an array of unsigned integer values into the dst byte array. -func (e Encoder) AppendUints(dst []byte, vals []uint) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendUint(dst, v) - } - return dst -} - -// AppendUint8 encodes and inserts a unsigned int8 value into the dst byte array. -func (e Encoder) AppendUint8(dst []byte, val uint8) []byte { - return e.AppendUint(dst, uint(val)) -} - -// AppendUints8 encodes and inserts an array of uint8 values into the dst byte array. -func (e Encoder) AppendUints8(dst []byte, vals []uint8) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendUint8(dst, v) - } - return dst -} - -// AppendUint16 encodes and inserts a uint16 value into the dst byte array. -func (e Encoder) AppendUint16(dst []byte, val uint16) []byte { - return e.AppendUint(dst, uint(val)) -} - -// AppendUints16 encodes and inserts an array of uint16 values into the dst byte array. -func (e Encoder) AppendUints16(dst []byte, vals []uint16) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendUint16(dst, v) - } - return dst -} - -// AppendUint32 encodes and inserts a uint32 value into the dst byte array. -func (e Encoder) AppendUint32(dst []byte, val uint32) []byte { - return e.AppendUint(dst, uint(val)) -} - -// AppendUints32 encodes and inserts an array of uint32 values into the dst byte array. -func (e Encoder) AppendUints32(dst []byte, vals []uint32) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendUint32(dst, v) - } - return dst -} - -// AppendUint64 encodes and inserts a uint64 value into the dst byte array. -func (Encoder) AppendUint64(dst []byte, val uint64) []byte { - major := majorTypeUnsignedInt - contentVal := val - if contentVal <= additionalMax { - lb := byte(contentVal) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, contentVal) - } - return dst -} - -// AppendUints64 encodes and inserts an array of uint64 values into the dst byte array. -func (e Encoder) AppendUints64(dst []byte, vals []uint64) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendUint64(dst, v) - } - return dst -} - -// AppendFloat32 encodes and inserts a single precision float value into the dst byte array. -func (Encoder) AppendFloat32(dst []byte, val float32) []byte { - switch { - case math.IsNaN(float64(val)): - return append(dst, "\xfa\x7f\xc0\x00\x00"...) - case math.IsInf(float64(val), 1): - return append(dst, "\xfa\x7f\x80\x00\x00"...) - case math.IsInf(float64(val), -1): - return append(dst, "\xfa\xff\x80\x00\x00"...) - } - major := majorTypeSimpleAndFloat - subType := additionalTypeFloat32 - n := math.Float32bits(val) - var buf [4]byte - for i := uint(0); i < 4; i++ { - buf[i] = byte(n >> ((3 - i) * 8)) - } - return append(append(dst, major|subType), buf[0], buf[1], buf[2], buf[3]) -} - -// AppendFloats32 encodes and inserts an array of single precision float value into the dst byte array. -func (e Encoder) AppendFloats32(dst []byte, vals []float32) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendFloat32(dst, v) - } - return dst -} - -// AppendFloat64 encodes and inserts a double precision float value into the dst byte array. -func (Encoder) AppendFloat64(dst []byte, val float64) []byte { - switch { - case math.IsNaN(val): - return append(dst, "\xfb\x7f\xf8\x00\x00\x00\x00\x00\x00"...) - case math.IsInf(val, 1): - return append(dst, "\xfb\x7f\xf0\x00\x00\x00\x00\x00\x00"...) - case math.IsInf(val, -1): - return append(dst, "\xfb\xff\xf0\x00\x00\x00\x00\x00\x00"...) - } - major := majorTypeSimpleAndFloat - subType := additionalTypeFloat64 - n := math.Float64bits(val) - dst = append(dst, major|subType) - for i := uint(1); i <= 8; i++ { - b := byte(n >> ((8 - i) * 8)) - dst = append(dst, b) - } - return dst -} - -// AppendFloats64 encodes and inserts an array of double precision float values into the dst byte array. -func (e Encoder) AppendFloats64(dst []byte, vals []float64) []byte { - major := majorTypeArray - l := len(vals) - if l == 0 { - return e.AppendArrayEnd(e.AppendArrayStart(dst)) - } - if l <= additionalMax { - lb := byte(l) - dst = append(dst, major|lb) - } else { - dst = appendCborTypePrefix(dst, major, uint64(l)) - } - for _, v := range vals { - dst = e.AppendFloat64(dst, v) - } - return dst -} - -// AppendInterface takes an arbitrary object and converts it to JSON and embeds it dst. -func (e Encoder) AppendInterface(dst []byte, i interface{}) []byte { - marshaled, err := JSONMarshalFunc(i) - if err != nil { - return e.AppendString(dst, fmt.Sprintf("marshaling error: %v", err)) - } - return AppendEmbeddedJSON(dst, marshaled) -} - -// AppendIPAddr encodes and inserts an IP Address (IPv4 or IPv6). -func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte { - dst = append(dst, majorTypeTags|additionalTypeIntUint16) - dst = append(dst, byte(additionalTypeTagNetworkAddr>>8)) - dst = append(dst, byte(additionalTypeTagNetworkAddr&0xff)) - return e.AppendBytes(dst, ip) -} - -// AppendIPPrefix encodes and inserts an IP Address Prefix (Address + Mask Length). -func (e Encoder) AppendIPPrefix(dst []byte, pfx net.IPNet) []byte { - dst = append(dst, majorTypeTags|additionalTypeIntUint16) - dst = append(dst, byte(additionalTypeTagNetworkPrefix>>8)) - dst = append(dst, byte(additionalTypeTagNetworkPrefix&0xff)) - - // Prefix is a tuple (aka MAP of 1 pair of elements) - - // first element is prefix, second is mask length. - dst = append(dst, majorTypeMap|0x1) - dst = e.AppendBytes(dst, pfx.IP) - maskLen, _ := pfx.Mask.Size() - return e.AppendUint8(dst, uint8(maskLen)) -} - -// AppendMACAddr encodes and inserts a Hardware (MAC) address. -func (e Encoder) AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte { - dst = append(dst, majorTypeTags|additionalTypeIntUint16) - dst = append(dst, byte(additionalTypeTagNetworkAddr>>8)) - dst = append(dst, byte(additionalTypeTagNetworkAddr&0xff)) - return e.AppendBytes(dst, ha) -} - -// AppendHex adds a TAG and inserts a hex bytes as a string. -func (e Encoder) AppendHex(dst []byte, val []byte) []byte { - dst = append(dst, majorTypeTags|additionalTypeIntUint16) - dst = append(dst, byte(additionalTypeTagHexString>>8)) - dst = append(dst, byte(additionalTypeTagHexString&0xff)) - return e.AppendBytes(dst, val) -} diff --git a/vendor/github.com/rs/zerolog/internal/json/base.go b/vendor/github.com/rs/zerolog/internal/json/base.go deleted file mode 100644 index 09ec59f4..00000000 --- a/vendor/github.com/rs/zerolog/internal/json/base.go +++ /dev/null @@ -1,19 +0,0 @@ -package json - -// JSONMarshalFunc is used to marshal interface to JSON encoded byte slice. -// Making it package level instead of embedded in Encoder brings -// some extra efforts at importing, but avoids value copy when the functions -// of Encoder being invoked. -// DO REMEMBER to set this variable at importing, or -// you might get a nil pointer dereference panic at runtime. -var JSONMarshalFunc func(v interface{}) ([]byte, error) - -type Encoder struct{} - -// AppendKey appends a new key to the output JSON. -func (e Encoder) AppendKey(dst []byte, key string) []byte { - if dst[len(dst)-1] != '{' { - dst = append(dst, ',') - } - return append(e.AppendString(dst, key), ':') -} diff --git a/vendor/github.com/rs/zerolog/internal/json/bytes.go b/vendor/github.com/rs/zerolog/internal/json/bytes.go deleted file mode 100644 index de64120d..00000000 --- a/vendor/github.com/rs/zerolog/internal/json/bytes.go +++ /dev/null @@ -1,85 +0,0 @@ -package json - -import "unicode/utf8" - -// AppendBytes is a mirror of appendString with []byte arg -func (Encoder) AppendBytes(dst, s []byte) []byte { - dst = append(dst, '"') - for i := 0; i < len(s); i++ { - if !noEscapeTable[s[i]] { - dst = appendBytesComplex(dst, s, i) - return append(dst, '"') - } - } - dst = append(dst, s...) - return append(dst, '"') -} - -// AppendHex encodes the input bytes to a hex string and appends -// the encoded string to the input byte slice. -// -// The operation loops though each byte and encodes it as hex using -// the hex lookup table. -func (Encoder) AppendHex(dst, s []byte) []byte { - dst = append(dst, '"') - for _, v := range s { - dst = append(dst, hex[v>>4], hex[v&0x0f]) - } - return append(dst, '"') -} - -// appendBytesComplex is a mirror of the appendStringComplex -// with []byte arg -func appendBytesComplex(dst, s []byte, i int) []byte { - start := 0 - for i < len(s) { - b := s[i] - if b >= utf8.RuneSelf { - r, size := utf8.DecodeRune(s[i:]) - if r == utf8.RuneError && size == 1 { - if start < i { - dst = append(dst, s[start:i]...) - } - dst = append(dst, `\ufffd`...) - i += size - start = i - continue - } - i += size - continue - } - if noEscapeTable[b] { - i++ - continue - } - // We encountered a character that needs to be encoded. - // Let's append the previous simple characters to the byte slice - // and switch our operation to read and encode the remainder - // characters byte-by-byte. - if start < i { - dst = append(dst, s[start:i]...) - } - switch b { - case '"', '\\': - dst = append(dst, '\\', b) - case '\b': - dst = append(dst, '\\', 'b') - case '\f': - dst = append(dst, '\\', 'f') - case '\n': - dst = append(dst, '\\', 'n') - case '\r': - dst = append(dst, '\\', 'r') - case '\t': - dst = append(dst, '\\', 't') - default: - dst = append(dst, '\\', 'u', '0', '0', hex[b>>4], hex[b&0xF]) - } - i++ - start = i - } - if start < len(s) { - dst = append(dst, s[start:]...) - } - return dst -} diff --git a/vendor/github.com/rs/zerolog/internal/json/string.go b/vendor/github.com/rs/zerolog/internal/json/string.go deleted file mode 100644 index fd7770f2..00000000 --- a/vendor/github.com/rs/zerolog/internal/json/string.go +++ /dev/null @@ -1,149 +0,0 @@ -package json - -import ( - "fmt" - "unicode/utf8" -) - -const hex = "0123456789abcdef" - -var noEscapeTable = [256]bool{} - -func init() { - for i := 0; i <= 0x7e; i++ { - noEscapeTable[i] = i >= 0x20 && i != '\\' && i != '"' - } -} - -// AppendStrings encodes the input strings to json and -// appends the encoded string list to the input byte slice. -func (e Encoder) AppendStrings(dst []byte, vals []string) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = e.AppendString(dst, vals[0]) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = e.AppendString(append(dst, ','), val) - } - } - dst = append(dst, ']') - return dst -} - -// AppendString encodes the input string to json and appends -// the encoded string to the input byte slice. -// -// The operation loops though each byte in the string looking -// for characters that need json or utf8 encoding. If the string -// does not need encoding, then the string is appended in its -// entirety to the byte slice. -// If we encounter a byte that does need encoding, switch up -// the operation and perform a byte-by-byte read-encode-append. -func (Encoder) AppendString(dst []byte, s string) []byte { - // Start with a double quote. - dst = append(dst, '"') - // Loop through each character in the string. - for i := 0; i < len(s); i++ { - // Check if the character needs encoding. Control characters, slashes, - // and the double quote need json encoding. Bytes above the ascii - // boundary needs utf8 encoding. - if !noEscapeTable[s[i]] { - // We encountered a character that needs to be encoded. Switch - // to complex version of the algorithm. - dst = appendStringComplex(dst, s, i) - return append(dst, '"') - } - } - // The string has no need for encoding and therefore is directly - // appended to the byte slice. - dst = append(dst, s...) - // End with a double quote - return append(dst, '"') -} - -// AppendStringers encodes the provided Stringer list to json and -// appends the encoded Stringer list to the input byte slice. -func (e Encoder) AppendStringers(dst []byte, vals []fmt.Stringer) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = e.AppendStringer(dst, vals[0]) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = e.AppendStringer(append(dst, ','), val) - } - } - return append(dst, ']') -} - -// AppendStringer encodes the input Stringer to json and appends the -// encoded Stringer value to the input byte slice. -func (e Encoder) AppendStringer(dst []byte, val fmt.Stringer) []byte { - if val == nil { - return e.AppendInterface(dst, nil) - } - return e.AppendString(dst, val.String()) -} - -//// appendStringComplex is used by appendString to take over an in -// progress JSON string encoding that encountered a character that needs -// to be encoded. -func appendStringComplex(dst []byte, s string, i int) []byte { - start := 0 - for i < len(s) { - b := s[i] - if b >= utf8.RuneSelf { - r, size := utf8.DecodeRuneInString(s[i:]) - if r == utf8.RuneError && size == 1 { - // In case of error, first append previous simple characters to - // the byte slice if any and append a replacement character code - // in place of the invalid sequence. - if start < i { - dst = append(dst, s[start:i]...) - } - dst = append(dst, `\ufffd`...) - i += size - start = i - continue - } - i += size - continue - } - if noEscapeTable[b] { - i++ - continue - } - // We encountered a character that needs to be encoded. - // Let's append the previous simple characters to the byte slice - // and switch our operation to read and encode the remainder - // characters byte-by-byte. - if start < i { - dst = append(dst, s[start:i]...) - } - switch b { - case '"', '\\': - dst = append(dst, '\\', b) - case '\b': - dst = append(dst, '\\', 'b') - case '\f': - dst = append(dst, '\\', 'f') - case '\n': - dst = append(dst, '\\', 'n') - case '\r': - dst = append(dst, '\\', 'r') - case '\t': - dst = append(dst, '\\', 't') - default: - dst = append(dst, '\\', 'u', '0', '0', hex[b>>4], hex[b&0xF]) - } - i++ - start = i - } - if start < len(s) { - dst = append(dst, s[start:]...) - } - return dst -} diff --git a/vendor/github.com/rs/zerolog/internal/json/time.go b/vendor/github.com/rs/zerolog/internal/json/time.go deleted file mode 100644 index 6a8dc912..00000000 --- a/vendor/github.com/rs/zerolog/internal/json/time.go +++ /dev/null @@ -1,113 +0,0 @@ -package json - -import ( - "strconv" - "time" -) - -const ( - // Import from zerolog/global.go - timeFormatUnix = "" - timeFormatUnixMs = "UNIXMS" - timeFormatUnixMicro = "UNIXMICRO" - timeFormatUnixNano = "UNIXNANO" -) - -// AppendTime formats the input time with the given format -// and appends the encoded string to the input byte slice. -func (e Encoder) AppendTime(dst []byte, t time.Time, format string) []byte { - switch format { - case timeFormatUnix: - return e.AppendInt64(dst, t.Unix()) - case timeFormatUnixMs: - return e.AppendInt64(dst, t.UnixNano()/1000000) - case timeFormatUnixMicro: - return e.AppendInt64(dst, t.UnixNano()/1000) - case timeFormatUnixNano: - return e.AppendInt64(dst, t.UnixNano()) - } - return append(t.AppendFormat(append(dst, '"'), format), '"') -} - -// AppendTimes converts the input times with the given format -// and appends the encoded string list to the input byte slice. -func (Encoder) AppendTimes(dst []byte, vals []time.Time, format string) []byte { - switch format { - case timeFormatUnix: - return appendUnixTimes(dst, vals) - case timeFormatUnixMs: - return appendUnixNanoTimes(dst, vals, 1000000) - case timeFormatUnixMicro: - return appendUnixNanoTimes(dst, vals, 1000) - case timeFormatUnixNano: - return appendUnixNanoTimes(dst, vals, 1) - } - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = append(vals[0].AppendFormat(append(dst, '"'), format), '"') - if len(vals) > 1 { - for _, t := range vals[1:] { - dst = append(t.AppendFormat(append(dst, ',', '"'), format), '"') - } - } - dst = append(dst, ']') - return dst -} - -func appendUnixTimes(dst []byte, vals []time.Time) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendInt(dst, vals[0].Unix(), 10) - if len(vals) > 1 { - for _, t := range vals[1:] { - dst = strconv.AppendInt(append(dst, ','), t.Unix(), 10) - } - } - dst = append(dst, ']') - return dst -} - -func appendUnixNanoTimes(dst []byte, vals []time.Time, div int64) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendInt(dst, vals[0].UnixNano()/div, 10) - if len(vals) > 1 { - for _, t := range vals[1:] { - dst = strconv.AppendInt(append(dst, ','), t.UnixNano()/div, 10) - } - } - dst = append(dst, ']') - return dst -} - -// AppendDuration formats the input duration with the given unit & format -// and appends the encoded string to the input byte slice. -func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte { - if useInt { - return strconv.AppendInt(dst, int64(d/unit), 10) - } - return e.AppendFloat64(dst, float64(d)/float64(unit)) -} - -// AppendDurations formats the input durations with the given unit & format -// and appends the encoded string list to the input byte slice. -func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = e.AppendDuration(dst, vals[0], unit, useInt) - if len(vals) > 1 { - for _, d := range vals[1:] { - dst = e.AppendDuration(append(dst, ','), d, unit, useInt) - } - } - dst = append(dst, ']') - return dst -} diff --git a/vendor/github.com/rs/zerolog/internal/json/types.go b/vendor/github.com/rs/zerolog/internal/json/types.go deleted file mode 100644 index ad7f7a88..00000000 --- a/vendor/github.com/rs/zerolog/internal/json/types.go +++ /dev/null @@ -1,405 +0,0 @@ -package json - -import ( - "fmt" - "math" - "net" - "strconv" -) - -// AppendNil inserts a 'Nil' object into the dst byte array. -func (Encoder) AppendNil(dst []byte) []byte { - return append(dst, "null"...) -} - -// AppendBeginMarker inserts a map start into the dst byte array. -func (Encoder) AppendBeginMarker(dst []byte) []byte { - return append(dst, '{') -} - -// AppendEndMarker inserts a map end into the dst byte array. -func (Encoder) AppendEndMarker(dst []byte) []byte { - return append(dst, '}') -} - -// AppendLineBreak appends a line break. -func (Encoder) AppendLineBreak(dst []byte) []byte { - return append(dst, '\n') -} - -// AppendArrayStart adds markers to indicate the start of an array. -func (Encoder) AppendArrayStart(dst []byte) []byte { - return append(dst, '[') -} - -// AppendArrayEnd adds markers to indicate the end of an array. -func (Encoder) AppendArrayEnd(dst []byte) []byte { - return append(dst, ']') -} - -// AppendArrayDelim adds markers to indicate end of a particular array element. -func (Encoder) AppendArrayDelim(dst []byte) []byte { - if len(dst) > 0 { - return append(dst, ',') - } - return dst -} - -// AppendBool converts the input bool to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendBool(dst []byte, val bool) []byte { - return strconv.AppendBool(dst, val) -} - -// AppendBools encodes the input bools to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendBools(dst []byte, vals []bool) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendBool(dst, vals[0]) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendBool(append(dst, ','), val) - } - } - dst = append(dst, ']') - return dst -} - -// AppendInt converts the input int to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendInt(dst []byte, val int) []byte { - return strconv.AppendInt(dst, int64(val), 10) -} - -// AppendInts encodes the input ints to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendInts(dst []byte, vals []int) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendInt(dst, int64(vals[0]), 10) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendInt(append(dst, ','), int64(val), 10) - } - } - dst = append(dst, ']') - return dst -} - -// AppendInt8 converts the input []int8 to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendInt8(dst []byte, val int8) []byte { - return strconv.AppendInt(dst, int64(val), 10) -} - -// AppendInts8 encodes the input int8s to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendInts8(dst []byte, vals []int8) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendInt(dst, int64(vals[0]), 10) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendInt(append(dst, ','), int64(val), 10) - } - } - dst = append(dst, ']') - return dst -} - -// AppendInt16 converts the input int16 to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendInt16(dst []byte, val int16) []byte { - return strconv.AppendInt(dst, int64(val), 10) -} - -// AppendInts16 encodes the input int16s to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendInts16(dst []byte, vals []int16) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendInt(dst, int64(vals[0]), 10) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendInt(append(dst, ','), int64(val), 10) - } - } - dst = append(dst, ']') - return dst -} - -// AppendInt32 converts the input int32 to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendInt32(dst []byte, val int32) []byte { - return strconv.AppendInt(dst, int64(val), 10) -} - -// AppendInts32 encodes the input int32s to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendInts32(dst []byte, vals []int32) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendInt(dst, int64(vals[0]), 10) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendInt(append(dst, ','), int64(val), 10) - } - } - dst = append(dst, ']') - return dst -} - -// AppendInt64 converts the input int64 to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendInt64(dst []byte, val int64) []byte { - return strconv.AppendInt(dst, val, 10) -} - -// AppendInts64 encodes the input int64s to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendInts64(dst []byte, vals []int64) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendInt(dst, vals[0], 10) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendInt(append(dst, ','), val, 10) - } - } - dst = append(dst, ']') - return dst -} - -// AppendUint converts the input uint to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendUint(dst []byte, val uint) []byte { - return strconv.AppendUint(dst, uint64(val), 10) -} - -// AppendUints encodes the input uints to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendUints(dst []byte, vals []uint) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendUint(dst, uint64(vals[0]), 10) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendUint(append(dst, ','), uint64(val), 10) - } - } - dst = append(dst, ']') - return dst -} - -// AppendUint8 converts the input uint8 to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendUint8(dst []byte, val uint8) []byte { - return strconv.AppendUint(dst, uint64(val), 10) -} - -// AppendUints8 encodes the input uint8s to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendUints8(dst []byte, vals []uint8) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendUint(dst, uint64(vals[0]), 10) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendUint(append(dst, ','), uint64(val), 10) - } - } - dst = append(dst, ']') - return dst -} - -// AppendUint16 converts the input uint16 to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendUint16(dst []byte, val uint16) []byte { - return strconv.AppendUint(dst, uint64(val), 10) -} - -// AppendUints16 encodes the input uint16s to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendUints16(dst []byte, vals []uint16) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendUint(dst, uint64(vals[0]), 10) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendUint(append(dst, ','), uint64(val), 10) - } - } - dst = append(dst, ']') - return dst -} - -// AppendUint32 converts the input uint32 to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendUint32(dst []byte, val uint32) []byte { - return strconv.AppendUint(dst, uint64(val), 10) -} - -// AppendUints32 encodes the input uint32s to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendUints32(dst []byte, vals []uint32) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendUint(dst, uint64(vals[0]), 10) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendUint(append(dst, ','), uint64(val), 10) - } - } - dst = append(dst, ']') - return dst -} - -// AppendUint64 converts the input uint64 to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendUint64(dst []byte, val uint64) []byte { - return strconv.AppendUint(dst, val, 10) -} - -// AppendUints64 encodes the input uint64s to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendUints64(dst []byte, vals []uint64) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = strconv.AppendUint(dst, vals[0], 10) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = strconv.AppendUint(append(dst, ','), val, 10) - } - } - dst = append(dst, ']') - return dst -} - -func appendFloat(dst []byte, val float64, bitSize int) []byte { - // JSON does not permit NaN or Infinity. A typical JSON encoder would fail - // with an error, but a logging library wants the data to get through so we - // make a tradeoff and store those types as string. - switch { - case math.IsNaN(val): - return append(dst, `"NaN"`...) - case math.IsInf(val, 1): - return append(dst, `"+Inf"`...) - case math.IsInf(val, -1): - return append(dst, `"-Inf"`...) - } - return strconv.AppendFloat(dst, val, 'f', -1, bitSize) -} - -// AppendFloat32 converts the input float32 to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendFloat32(dst []byte, val float32) []byte { - return appendFloat(dst, float64(val), 32) -} - -// AppendFloats32 encodes the input float32s to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendFloats32(dst []byte, vals []float32) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = appendFloat(dst, float64(vals[0]), 32) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = appendFloat(append(dst, ','), float64(val), 32) - } - } - dst = append(dst, ']') - return dst -} - -// AppendFloat64 converts the input float64 to a string and -// appends the encoded string to the input byte slice. -func (Encoder) AppendFloat64(dst []byte, val float64) []byte { - return appendFloat(dst, val, 64) -} - -// AppendFloats64 encodes the input float64s to json and -// appends the encoded string list to the input byte slice. -func (Encoder) AppendFloats64(dst []byte, vals []float64) []byte { - if len(vals) == 0 { - return append(dst, '[', ']') - } - dst = append(dst, '[') - dst = appendFloat(dst, vals[0], 64) - if len(vals) > 1 { - for _, val := range vals[1:] { - dst = appendFloat(append(dst, ','), val, 64) - } - } - dst = append(dst, ']') - return dst -} - -// AppendInterface marshals the input interface to a string and -// appends the encoded string to the input byte slice. -func (e Encoder) AppendInterface(dst []byte, i interface{}) []byte { - marshaled, err := JSONMarshalFunc(i) - if err != nil { - return e.AppendString(dst, fmt.Sprintf("marshaling error: %v", err)) - } - return append(dst, marshaled...) -} - -// AppendObjectData takes in an object that is already in a byte array -// and adds it to the dst. -func (Encoder) AppendObjectData(dst []byte, o []byte) []byte { - // Three conditions apply here: - // 1. new content starts with '{' - which should be dropped OR - // 2. new content starts with '{' - which should be replaced with ',' - // to separate with existing content OR - // 3. existing content has already other fields - if o[0] == '{' { - if len(dst) > 1 { - dst = append(dst, ',') - } - o = o[1:] - } else if len(dst) > 1 { - dst = append(dst, ',') - } - return append(dst, o...) -} - -// AppendIPAddr adds IPv4 or IPv6 address to dst. -func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte { - return e.AppendString(dst, ip.String()) -} - -// AppendIPPrefix adds IPv4 or IPv6 Prefix (address & mask) to dst. -func (e Encoder) AppendIPPrefix(dst []byte, pfx net.IPNet) []byte { - return e.AppendString(dst, pfx.String()) - -} - -// AppendMACAddr adds MAC address to dst. -func (e Encoder) AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte { - return e.AppendString(dst, ha.String()) -} diff --git a/vendor/github.com/rs/zerolog/log.go b/vendor/github.com/rs/zerolog/log.go deleted file mode 100644 index efd2a330..00000000 --- a/vendor/github.com/rs/zerolog/log.go +++ /dev/null @@ -1,476 +0,0 @@ -// Package zerolog provides a lightweight logging library dedicated to JSON logging. -// -// A global Logger can be use for simple logging: -// -// import "github.com/rs/zerolog/log" -// -// log.Info().Msg("hello world") -// // Output: {"time":1494567715,"level":"info","message":"hello world"} -// -// NOTE: To import the global logger, import the "log" subpackage "github.com/rs/zerolog/log". -// -// Fields can be added to log messages: -// -// log.Info().Str("foo", "bar").Msg("hello world") -// // Output: {"time":1494567715,"level":"info","message":"hello world","foo":"bar"} -// -// Create logger instance to manage different outputs: -// -// logger := zerolog.New(os.Stderr).With().Timestamp().Logger() -// logger.Info(). -// Str("foo", "bar"). -// Msg("hello world") -// // Output: {"time":1494567715,"level":"info","message":"hello world","foo":"bar"} -// -// Sub-loggers let you chain loggers with additional context: -// -// sublogger := log.With().Str("component": "foo").Logger() -// sublogger.Info().Msg("hello world") -// // Output: {"time":1494567715,"level":"info","message":"hello world","component":"foo"} -// -// Level logging -// -// zerolog.SetGlobalLevel(zerolog.InfoLevel) -// -// log.Debug().Msg("filtered out message") -// log.Info().Msg("routed message") -// -// if e := log.Debug(); e.Enabled() { -// // Compute log output only if enabled. -// value := compute() -// e.Str("foo": value).Msg("some debug message") -// } -// // Output: {"level":"info","time":1494567715,"routed message"} -// -// Customize automatic field names: -// -// log.TimestampFieldName = "t" -// log.LevelFieldName = "p" -// log.MessageFieldName = "m" -// -// log.Info().Msg("hello world") -// // Output: {"t":1494567715,"p":"info","m":"hello world"} -// -// Log with no level and message: -// -// log.Log().Str("foo","bar").Msg("") -// // Output: {"time":1494567715,"foo":"bar"} -// -// Add contextual fields to global Logger: -// -// log.Logger = log.With().Str("foo", "bar").Logger() -// -// Sample logs: -// -// sampled := log.Sample(&zerolog.BasicSampler{N: 10}) -// sampled.Info().Msg("will be logged every 10 messages") -// -// Log with contextual hooks: -// -// // Create the hook: -// type SeverityHook struct{} -// -// func (h SeverityHook) Run(e *zerolog.Event, level zerolog.Level, msg string) { -// if level != zerolog.NoLevel { -// e.Str("severity", level.String()) -// } -// } -// -// // And use it: -// var h SeverityHook -// log := zerolog.New(os.Stdout).Hook(h) -// log.Warn().Msg("") -// // Output: {"level":"warn","severity":"warn"} -// -// -// Caveats -// -// There is no fields deduplication out-of-the-box. -// Using the same key multiple times creates new key in final JSON each time. -// -// logger := zerolog.New(os.Stderr).With().Timestamp().Logger() -// logger.Info(). -// Timestamp(). -// Msg("dup") -// // Output: {"level":"info","time":1494567715,"time":1494567715,"message":"dup"} -// -// In this case, many consumers will take the last value, -// but this is not guaranteed; check yours if in doubt. -package zerolog - -import ( - "errors" - "fmt" - "io" - "io/ioutil" - "os" - "strconv" -) - -// Level defines log levels. -type Level int8 - -const ( - // DebugLevel defines debug log level. - DebugLevel Level = iota - // InfoLevel defines info log level. - InfoLevel - // WarnLevel defines warn log level. - WarnLevel - // ErrorLevel defines error log level. - ErrorLevel - // FatalLevel defines fatal log level. - FatalLevel - // PanicLevel defines panic log level. - PanicLevel - // NoLevel defines an absent log level. - NoLevel - // Disabled disables the logger. - Disabled - - // TraceLevel defines trace log level. - TraceLevel Level = -1 - // Values less than TraceLevel are handled as numbers. -) - -func (l Level) String() string { - switch l { - case TraceLevel: - return LevelTraceValue - case DebugLevel: - return LevelDebugValue - case InfoLevel: - return LevelInfoValue - case WarnLevel: - return LevelWarnValue - case ErrorLevel: - return LevelErrorValue - case FatalLevel: - return LevelFatalValue - case PanicLevel: - return LevelPanicValue - case Disabled: - return "disabled" - case NoLevel: - return "" - } - return strconv.Itoa(int(l)) -} - -// ParseLevel converts a level string into a zerolog Level value. -// returns an error if the input string does not match known values. -func ParseLevel(levelStr string) (Level, error) { - switch levelStr { - case LevelFieldMarshalFunc(TraceLevel): - return TraceLevel, nil - case LevelFieldMarshalFunc(DebugLevel): - return DebugLevel, nil - case LevelFieldMarshalFunc(InfoLevel): - return InfoLevel, nil - case LevelFieldMarshalFunc(WarnLevel): - return WarnLevel, nil - case LevelFieldMarshalFunc(ErrorLevel): - return ErrorLevel, nil - case LevelFieldMarshalFunc(FatalLevel): - return FatalLevel, nil - case LevelFieldMarshalFunc(PanicLevel): - return PanicLevel, nil - case LevelFieldMarshalFunc(Disabled): - return Disabled, nil - case LevelFieldMarshalFunc(NoLevel): - return NoLevel, nil - } - i, err := strconv.Atoi(levelStr) - if err != nil { - return NoLevel, fmt.Errorf("Unknown Level String: '%s', defaulting to NoLevel", levelStr) - } - if i > 127 || i < -128 { - return NoLevel, fmt.Errorf("Out-Of-Bounds Level: '%d', defaulting to NoLevel", i) - } - return Level(i), nil -} - -// UnmarshalText implements encoding.TextUnmarshaler to allow for easy reading from toml/yaml/json formats -func (l *Level) UnmarshalText(text []byte) error { - if l == nil { - return errors.New("can't unmarshal a nil *Level") - } - var err error - *l, err = ParseLevel(string(text)) - return err -} - -// MarshalText implements encoding.TextMarshaler to allow for easy writing into toml/yaml/json formats -func (l Level) MarshalText() ([]byte, error) { - return []byte(LevelFieldMarshalFunc(l)), nil -} - -// A Logger represents an active logging object that generates lines -// of JSON output to an io.Writer. Each logging operation makes a single -// call to the Writer's Write method. There is no guarantee on access -// serialization to the Writer. If your Writer is not thread safe, -// you may consider a sync wrapper. -type Logger struct { - w LevelWriter - level Level - sampler Sampler - context []byte - hooks []Hook - stack bool -} - -// New creates a root logger with given output writer. If the output writer implements -// the LevelWriter interface, the WriteLevel method will be called instead of the Write -// one. -// -// Each logging operation makes a single call to the Writer's Write method. There is no -// guarantee on access serialization to the Writer. If your Writer is not thread safe, -// you may consider using sync wrapper. -func New(w io.Writer) Logger { - if w == nil { - w = ioutil.Discard - } - lw, ok := w.(LevelWriter) - if !ok { - lw = levelWriterAdapter{w} - } - return Logger{w: lw, level: TraceLevel} -} - -// Nop returns a disabled logger for which all operation are no-op. -func Nop() Logger { - return New(nil).Level(Disabled) -} - -// Output duplicates the current logger and sets w as its output. -func (l Logger) Output(w io.Writer) Logger { - l2 := New(w) - l2.level = l.level - l2.sampler = l.sampler - l2.stack = l.stack - if len(l.hooks) > 0 { - l2.hooks = append(l2.hooks, l.hooks...) - } - if l.context != nil { - l2.context = make([]byte, len(l.context), cap(l.context)) - copy(l2.context, l.context) - } - return l2 -} - -// With creates a child logger with the field added to its context. -func (l Logger) With() Context { - context := l.context - l.context = make([]byte, 0, 500) - if context != nil { - l.context = append(l.context, context...) - } else { - // This is needed for AppendKey to not check len of input - // thus making it inlinable - l.context = enc.AppendBeginMarker(l.context) - } - return Context{l} -} - -// UpdateContext updates the internal logger's context. -// -// Use this method with caution. If unsure, prefer the With method. -func (l *Logger) UpdateContext(update func(c Context) Context) { - if l == disabledLogger { - return - } - if cap(l.context) == 0 { - l.context = make([]byte, 0, 500) - } - if len(l.context) == 0 { - l.context = enc.AppendBeginMarker(l.context) - } - c := update(Context{*l}) - l.context = c.l.context -} - -// Level creates a child logger with the minimum accepted level set to level. -func (l Logger) Level(lvl Level) Logger { - l.level = lvl - return l -} - -// GetLevel returns the current Level of l. -func (l Logger) GetLevel() Level { - return l.level -} - -// Sample returns a logger with the s sampler. -func (l Logger) Sample(s Sampler) Logger { - l.sampler = s - return l -} - -// Hook returns a logger with the h Hook. -func (l Logger) Hook(h Hook) Logger { - l.hooks = append(l.hooks, h) - return l -} - -// Trace starts a new message with trace level. -// -// You must call Msg on the returned event in order to send the event. -func (l *Logger) Trace() *Event { - return l.newEvent(TraceLevel, nil) -} - -// Debug starts a new message with debug level. -// -// You must call Msg on the returned event in order to send the event. -func (l *Logger) Debug() *Event { - return l.newEvent(DebugLevel, nil) -} - -// Info starts a new message with info level. -// -// You must call Msg on the returned event in order to send the event. -func (l *Logger) Info() *Event { - return l.newEvent(InfoLevel, nil) -} - -// Warn starts a new message with warn level. -// -// You must call Msg on the returned event in order to send the event. -func (l *Logger) Warn() *Event { - return l.newEvent(WarnLevel, nil) -} - -// Error starts a new message with error level. -// -// You must call Msg on the returned event in order to send the event. -func (l *Logger) Error() *Event { - return l.newEvent(ErrorLevel, nil) -} - -// Err starts a new message with error level with err as a field if not nil or -// with info level if err is nil. -// -// You must call Msg on the returned event in order to send the event. -func (l *Logger) Err(err error) *Event { - if err != nil { - return l.Error().Err(err) - } - - return l.Info() -} - -// Fatal starts a new message with fatal level. The os.Exit(1) function -// is called by the Msg method, which terminates the program immediately. -// -// You must call Msg on the returned event in order to send the event. -func (l *Logger) Fatal() *Event { - return l.newEvent(FatalLevel, func(msg string) { os.Exit(1) }) -} - -// Panic starts a new message with panic level. The panic() function -// is called by the Msg method, which stops the ordinary flow of a goroutine. -// -// You must call Msg on the returned event in order to send the event. -func (l *Logger) Panic() *Event { - return l.newEvent(PanicLevel, func(msg string) { panic(msg) }) -} - -// WithLevel starts a new message with level. Unlike Fatal and Panic -// methods, WithLevel does not terminate the program or stop the ordinary -// flow of a goroutine when used with their respective levels. -// -// You must call Msg on the returned event in order to send the event. -func (l *Logger) WithLevel(level Level) *Event { - switch level { - case TraceLevel: - return l.Trace() - case DebugLevel: - return l.Debug() - case InfoLevel: - return l.Info() - case WarnLevel: - return l.Warn() - case ErrorLevel: - return l.Error() - case FatalLevel: - return l.newEvent(FatalLevel, nil) - case PanicLevel: - return l.newEvent(PanicLevel, nil) - case NoLevel: - return l.Log() - case Disabled: - return nil - default: - return l.newEvent(level, nil) - } -} - -// Log starts a new message with no level. Setting GlobalLevel to Disabled -// will still disable events produced by this method. -// -// You must call Msg on the returned event in order to send the event. -func (l *Logger) Log() *Event { - return l.newEvent(NoLevel, nil) -} - -// Print sends a log event using debug level and no extra field. -// Arguments are handled in the manner of fmt.Print. -func (l *Logger) Print(v ...interface{}) { - if e := l.Debug(); e.Enabled() { - e.CallerSkipFrame(1).Msg(fmt.Sprint(v...)) - } -} - -// Printf sends a log event using debug level and no extra field. -// Arguments are handled in the manner of fmt.Printf. -func (l *Logger) Printf(format string, v ...interface{}) { - if e := l.Debug(); e.Enabled() { - e.CallerSkipFrame(1).Msg(fmt.Sprintf(format, v...)) - } -} - -// Write implements the io.Writer interface. This is useful to set as a writer -// for the standard library log. -func (l Logger) Write(p []byte) (n int, err error) { - n = len(p) - if n > 0 && p[n-1] == '\n' { - // Trim CR added by stdlog. - p = p[0 : n-1] - } - l.Log().CallerSkipFrame(1).Msg(string(p)) - return -} - -func (l *Logger) newEvent(level Level, done func(string)) *Event { - enabled := l.should(level) - if !enabled { - if done != nil { - done("") - } - return nil - } - e := newEvent(l.w, level) - e.done = done - e.ch = l.hooks - if level != NoLevel && LevelFieldName != "" { - e.Str(LevelFieldName, LevelFieldMarshalFunc(level)) - } - if l.context != nil && len(l.context) > 1 { - e.buf = enc.AppendObjectData(e.buf, l.context) - } - if l.stack { - e.Stack() - } - return e -} - -// should returns true if the log event should be logged. -func (l *Logger) should(lvl Level) bool { - if lvl < l.level || lvl < GlobalLevel() { - return false - } - if l.sampler != nil && !samplingDisabled() { - return l.sampler.Sample(lvl) - } - return true -} diff --git a/vendor/github.com/rs/zerolog/not_go112.go b/vendor/github.com/rs/zerolog/not_go112.go deleted file mode 100644 index 4c43c9e7..00000000 --- a/vendor/github.com/rs/zerolog/not_go112.go +++ /dev/null @@ -1,5 +0,0 @@ -// +build !go1.12 - -package zerolog - -const contextCallerSkipFrameCount = 3 diff --git a/vendor/github.com/rs/zerolog/pretty.png b/vendor/github.com/rs/zerolog/pretty.png deleted file mode 100644 index 242033686debf04c5b1756c166d05d09767594e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 84064 zcmc$^Wl&vB69#w_Ah^2|+}$-;aCdiicM0z9?(Q1g-GVy=cXzm4miNnUZEfxU-9B}z z&Y3$k=S+9c%+pVIxV)?wJPZyD004lO5EoGd0KSz00AHY>zJ9h;J?*{%05EkH!ouy zB31z6QCag`#I8A6u@lXSbVw0j7$^2!8$Aqv1w4&vNKrD#Pfx*2=$6xu^c#1I&<;daPf9$p?mnOYS6}HEl+qT>TYR6w2rTGzcV;6 ze_*iaU?&cZE8nU!6biu|hJ&|NL3|uJ0PV&mlB13o6KTk#un1`MT+okFSU42NfcF-& zdy{)nud$9Pq`U@Ms|9%r4u^FCB*|V*rJ~VJ-x!k0qex7LV;k*ltC;!K&`>z0X?LEq z6S9H;Cc5-W*o}-d{1#cT?&0&p8cC>_FPjwN7MPNT$!um&!pVGx;h;Ip*z$W!v!PHL zFJqtDXc|e?rQV%yp_CUu@Z#7Xcx6!xqtOblPEG?!t_p%#jwO?$tG{F8k36Upe18pOJBiNI|`)^!tn)1Q^@B#c)q|qX##cDJ_7vLlc z#4-OxfHk&FVO0l-X%A_49f}m@ZypwkmIiM<8o=vuaHo$<8)`@y{7{E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LjYF%S_Cl=nU9pxk0a;&=}L5Ls=_3%z2&9>t5A05c-=mFMAnf_lW{CCWYgt5TVLxywlOP)m)$@}5| z;)ueL4w=-HLN3n!9HBnVJnb2cc5gmr@jy)rRhm>r8(b5=du_kw1*`|4k;lqOJLrcJ zw(%*z_<=Y107`VlAeX$Aiv?(w9t&ds%c1|ChyU+9@_&uT)zkkw{v3PBKJ1=Y^YDc` za2OVMSv_|PQ+G=db5~2?=^7soA1@~lFDEar7LTw9uYd^8a}W=Y2oDeDP4Mggse^-) zg{>9j|J)&xL}U->@a*avY|YI@%$=MeuC~@T?$@OM{p#^6XJ>oM$BK^TTpW-2cz9oM wtK5DC^r8889}7!2b5~nucUvdNYcjTO&i1Ad8rqa5;3L-*WmRP=q}~Sq2RF(BlK=n! diff --git a/vendor/github.com/rs/zerolog/sampler.go b/vendor/github.com/rs/zerolog/sampler.go deleted file mode 100644 index 1be98c4f..00000000 --- a/vendor/github.com/rs/zerolog/sampler.go +++ /dev/null @@ -1,134 +0,0 @@ -package zerolog - -import ( - "math/rand" - "sync/atomic" - "time" -) - -var ( - // Often samples log every ~ 10 events. - Often = RandomSampler(10) - // Sometimes samples log every ~ 100 events. - Sometimes = RandomSampler(100) - // Rarely samples log every ~ 1000 events. - Rarely = RandomSampler(1000) -) - -// Sampler defines an interface to a log sampler. -type Sampler interface { - // Sample returns true if the event should be part of the sample, false if - // the event should be dropped. - Sample(lvl Level) bool -} - -// RandomSampler use a PRNG to randomly sample an event out of N events, -// regardless of their level. -type RandomSampler uint32 - -// Sample implements the Sampler interface. -func (s RandomSampler) Sample(lvl Level) bool { - if s <= 0 { - return false - } - if rand.Intn(int(s)) != 0 { - return false - } - return true -} - -// BasicSampler is a sampler that will send every Nth events, regardless of -// their level. -type BasicSampler struct { - N uint32 - counter uint32 -} - -// Sample implements the Sampler interface. -func (s *BasicSampler) Sample(lvl Level) bool { - n := s.N - if n == 1 { - return true - } - c := atomic.AddUint32(&s.counter, 1) - return c%n == 1 -} - -// BurstSampler lets Burst events pass per Period then pass the decision to -// NextSampler. If Sampler is not set, all subsequent events are rejected. -type BurstSampler struct { - // Burst is the maximum number of event per period allowed before calling - // NextSampler. - Burst uint32 - // Period defines the burst period. If 0, NextSampler is always called. - Period time.Duration - // NextSampler is the sampler used after the burst is reached. If nil, - // events are always rejected after the burst. - NextSampler Sampler - - counter uint32 - resetAt int64 -} - -// Sample implements the Sampler interface. -func (s *BurstSampler) Sample(lvl Level) bool { - if s.Burst > 0 && s.Period > 0 { - if s.inc() <= s.Burst { - return true - } - } - if s.NextSampler == nil { - return false - } - return s.NextSampler.Sample(lvl) -} - -func (s *BurstSampler) inc() uint32 { - now := time.Now().UnixNano() - resetAt := atomic.LoadInt64(&s.resetAt) - var c uint32 - if now > resetAt { - c = 1 - atomic.StoreUint32(&s.counter, c) - newResetAt := now + s.Period.Nanoseconds() - reset := atomic.CompareAndSwapInt64(&s.resetAt, resetAt, newResetAt) - if !reset { - // Lost the race with another goroutine trying to reset. - c = atomic.AddUint32(&s.counter, 1) - } - } else { - c = atomic.AddUint32(&s.counter, 1) - } - return c -} - -// LevelSampler applies a different sampler for each level. -type LevelSampler struct { - TraceSampler, DebugSampler, InfoSampler, WarnSampler, ErrorSampler Sampler -} - -func (s LevelSampler) Sample(lvl Level) bool { - switch lvl { - case TraceLevel: - if s.TraceSampler != nil { - return s.TraceSampler.Sample(lvl) - } - case DebugLevel: - if s.DebugSampler != nil { - return s.DebugSampler.Sample(lvl) - } - case InfoLevel: - if s.InfoSampler != nil { - return s.InfoSampler.Sample(lvl) - } - case WarnLevel: - if s.WarnSampler != nil { - return s.WarnSampler.Sample(lvl) - } - case ErrorLevel: - if s.ErrorSampler != nil { - return s.ErrorSampler.Sample(lvl) - } - } - return true -} diff --git a/vendor/github.com/rs/zerolog/syslog.go b/vendor/github.com/rs/zerolog/syslog.go deleted file mode 100644 index c4082830..00000000 --- a/vendor/github.com/rs/zerolog/syslog.go +++ /dev/null @@ -1,80 +0,0 @@ -// +build !windows -// +build !binary_log - -package zerolog - -import ( - "io" -) - -// See http://cee.mitre.org/language/1.0-beta1/clt.html#syslog -// or https://www.rsyslog.com/json-elasticsearch/ -const ceePrefix = "@cee:" - -// SyslogWriter is an interface matching a syslog.Writer struct. -type SyslogWriter interface { - io.Writer - Debug(m string) error - Info(m string) error - Warning(m string) error - Err(m string) error - Emerg(m string) error - Crit(m string) error -} - -type syslogWriter struct { - w SyslogWriter - prefix string -} - -// SyslogLevelWriter wraps a SyslogWriter and call the right syslog level -// method matching the zerolog level. -func SyslogLevelWriter(w SyslogWriter) LevelWriter { - return syslogWriter{w, ""} -} - -// SyslogCEEWriter wraps a SyslogWriter with a SyslogLevelWriter that adds a -// MITRE CEE prefix for JSON syslog entries, compatible with rsyslog -// and syslog-ng JSON logging support. -// See https://www.rsyslog.com/json-elasticsearch/ -func SyslogCEEWriter(w SyslogWriter) LevelWriter { - return syslogWriter{w, ceePrefix} -} - -func (sw syslogWriter) Write(p []byte) (n int, err error) { - var pn int - if sw.prefix != "" { - pn, err = sw.w.Write([]byte(sw.prefix)) - if err != nil { - return pn, err - } - } - n, err = sw.w.Write(p) - return pn + n, err -} - -// WriteLevel implements LevelWriter interface. -func (sw syslogWriter) WriteLevel(level Level, p []byte) (n int, err error) { - switch level { - case TraceLevel: - case DebugLevel: - err = sw.w.Debug(sw.prefix + string(p)) - case InfoLevel: - err = sw.w.Info(sw.prefix + string(p)) - case WarnLevel: - err = sw.w.Warning(sw.prefix + string(p)) - case ErrorLevel: - err = sw.w.Err(sw.prefix + string(p)) - case FatalLevel: - err = sw.w.Emerg(sw.prefix + string(p)) - case PanicLevel: - err = sw.w.Crit(sw.prefix + string(p)) - case NoLevel: - err = sw.w.Info(sw.prefix + string(p)) - default: - panic("invalid level") - } - // Any CEE prefix is not part of the message, so we don't include its length - n = len(p) - return -} diff --git a/vendor/github.com/rs/zerolog/writer.go b/vendor/github.com/rs/zerolog/writer.go deleted file mode 100644 index 26f5e632..00000000 --- a/vendor/github.com/rs/zerolog/writer.go +++ /dev/null @@ -1,154 +0,0 @@ -package zerolog - -import ( - "bytes" - "io" - "path" - "runtime" - "strconv" - "strings" - "sync" -) - -// LevelWriter defines as interface a writer may implement in order -// to receive level information with payload. -type LevelWriter interface { - io.Writer - WriteLevel(level Level, p []byte) (n int, err error) -} - -type levelWriterAdapter struct { - io.Writer -} - -func (lw levelWriterAdapter) WriteLevel(l Level, p []byte) (n int, err error) { - return lw.Write(p) -} - -type syncWriter struct { - mu sync.Mutex - lw LevelWriter -} - -// SyncWriter wraps w so that each call to Write is synchronized with a mutex. -// This syncer can be used to wrap the call to writer's Write method if it is -// not thread safe. Note that you do not need this wrapper for os.File Write -// operations on POSIX and Windows systems as they are already thread-safe. -func SyncWriter(w io.Writer) io.Writer { - if lw, ok := w.(LevelWriter); ok { - return &syncWriter{lw: lw} - } - return &syncWriter{lw: levelWriterAdapter{w}} -} - -// Write implements the io.Writer interface. -func (s *syncWriter) Write(p []byte) (n int, err error) { - s.mu.Lock() - defer s.mu.Unlock() - return s.lw.Write(p) -} - -// WriteLevel implements the LevelWriter interface. -func (s *syncWriter) WriteLevel(l Level, p []byte) (n int, err error) { - s.mu.Lock() - defer s.mu.Unlock() - return s.lw.WriteLevel(l, p) -} - -type multiLevelWriter struct { - writers []LevelWriter -} - -func (t multiLevelWriter) Write(p []byte) (n int, err error) { - for _, w := range t.writers { - if _n, _err := w.Write(p); err == nil { - n = _n - if _err != nil { - err = _err - } else if _n != len(p) { - err = io.ErrShortWrite - } - } - } - return n, err -} - -func (t multiLevelWriter) WriteLevel(l Level, p []byte) (n int, err error) { - for _, w := range t.writers { - if _n, _err := w.WriteLevel(l, p); err == nil { - n = _n - if _err != nil { - err = _err - } else if _n != len(p) { - err = io.ErrShortWrite - } - } - } - return n, err -} - -// MultiLevelWriter creates a writer that duplicates its writes to all the -// provided writers, similar to the Unix tee(1) command. If some writers -// implement LevelWriter, their WriteLevel method will be used instead of Write. -func MultiLevelWriter(writers ...io.Writer) LevelWriter { - lwriters := make([]LevelWriter, 0, len(writers)) - for _, w := range writers { - if lw, ok := w.(LevelWriter); ok { - lwriters = append(lwriters, lw) - } else { - lwriters = append(lwriters, levelWriterAdapter{w}) - } - } - return multiLevelWriter{lwriters} -} - -// TestingLog is the logging interface of testing.TB. -type TestingLog interface { - Log(args ...interface{}) - Logf(format string, args ...interface{}) - Helper() -} - -// TestWriter is a writer that writes to testing.TB. -type TestWriter struct { - T TestingLog - - // Frame skips caller frames to capture the original file and line numbers. - Frame int -} - -// NewTestWriter creates a writer that logs to the testing.TB. -func NewTestWriter(t TestingLog) TestWriter { - return TestWriter{T: t} -} - -// Write to testing.TB. -func (t TestWriter) Write(p []byte) (n int, err error) { - t.T.Helper() - - n = len(p) - - // Strip trailing newline because t.Log always adds one. - p = bytes.TrimRight(p, "\n") - - // Try to correct the log file and line number to the caller. - if t.Frame > 0 { - _, origFile, origLine, _ := runtime.Caller(1) - _, frameFile, frameLine, ok := runtime.Caller(1 + t.Frame) - if ok { - erase := strings.Repeat("\b", len(path.Base(origFile))+len(strconv.Itoa(origLine))+3) - t.T.Logf("%s%s:%d: %s", erase, path.Base(frameFile), frameLine, p) - return n, err - } - } - t.T.Log(string(p)) - - return n, err -} - -// ConsoleTestWriter creates an option that correctly sets the file frame depth for testing.TB log. -func ConsoleTestWriter(t TestingLog) func(w *ConsoleWriter) { - return func(w *ConsoleWriter) { - w.Out = TestWriter{T: t, Frame: 6} - } -} diff --git a/vendor/modules.txt b/vendor/modules.txt index dcd4b256..f54acb13 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -60,18 +60,14 @@ github.com/go-redis/redis/v8/internal/util github.com/golang/protobuf/proto # github.com/golang/snappy v0.0.3 ## explicit +# github.com/google/go-cmp v0.5.8 +## explicit; go 1.13 # github.com/gorilla/websocket v1.5.0 ## explicit; go 1.12 github.com/gorilla/websocket # github.com/jinzhu/copier v0.3.5 ## explicit; go 1.13 github.com/jinzhu/copier -# github.com/mattn/go-colorable v0.1.12 -## explicit; go 1.13 -github.com/mattn/go-colorable -# github.com/mattn/go-isatty v0.0.14 -## explicit; go 1.12 -github.com/mattn/go-isatty # github.com/pkg/errors v0.9.1 ## explicit github.com/pkg/errors @@ -81,11 +77,6 @@ github.com/pmezard/go-difflib/difflib # github.com/rs/xid v1.4.0 ## explicit; go 1.12 github.com/rs/xid -# github.com/rs/zerolog v1.28.0 -## explicit; go 1.15 -github.com/rs/zerolog -github.com/rs/zerolog/internal/cbor -github.com/rs/zerolog/internal/json # github.com/stretchr/testify v1.7.1 ## explicit; go 1.13 github.com/stretchr/testify/assert @@ -109,8 +100,6 @@ golang.org/x/net/trace # golang.org/x/sys v0.5.0 ## explicit; go 1.17 golang.org/x/sys/unix -# golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 -## explicit; go 1.11 # google.golang.org/protobuf v1.28.1 ## explicit; go 1.11 google.golang.org/protobuf/encoding/prototext