Skip to content

Commit

Permalink
feat: Remove unused HMACSha256 function and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Laisky committed Jul 1, 2024
1 parent 85f8e5e commit 34dbeb2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/Laisky/go-chaining v0.0.0-20180507092046-43dcdc5a21be
github.com/Laisky/golang-fifo v1.0.1-0.20240403091456-fc83d5e38c0b
github.com/Laisky/graphql v1.0.6
github.com/Laisky/zap v1.27.0
github.com/Laisky/zap v1.27.1-0.20240628060440-a253d90172e3
github.com/brianvoe/gofakeit/v6 v6.23.2
github.com/cespare/xxhash v1.1.0
github.com/corvus-ch/shamir v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/Laisky/golang-fifo v1.0.1-0.20240403091456-fc83d5e38c0b h1:o2BuVyXFkD
github.com/Laisky/golang-fifo v1.0.1-0.20240403091456-fc83d5e38c0b/go.mod h1:j90tUqwBaEncIzpAd6ZGPZHWjclgAyMY8fdOqsewitE=
github.com/Laisky/graphql v1.0.6 h1:NEULGxfxo+wbsW2OmqBXOMNUGgqo8uFjWNabwuNK10g=
github.com/Laisky/graphql v1.0.6/go.mod h1:zaKVqXmMQTnTkFJ2AA53oyBWMzlGCnzr3aodKTrtOxI=
github.com/Laisky/zap v1.27.0 h1:NEtFniRXOKUkEf9//FUiBkSIdgbB4V1H3khA/jmPZx4=
github.com/Laisky/zap v1.27.0/go.mod h1:HABqM5YDQlPq8w+Pmp9h/x9F6Vy+3oHBLP+2+pBoaJw=
github.com/Laisky/zap v1.27.1-0.20240628060440-a253d90172e3 h1:SD0siYXoInGc6MqVsmJrBJl4TNHYXfeGu92fRSUNnas=
github.com/Laisky/zap v1.27.1-0.20240628060440-a253d90172e3/go.mod h1:HABqM5YDQlPq8w+Pmp9h/x9F6Vy+3oHBLP+2+pBoaJw=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/brianvoe/gofakeit/v6 v6.23.2 h1:lVde18uhad5wII/f5RMVFLtdQNE0HaGFuBUXmYKk8i8=
Expand Down
49 changes: 49 additions & 0 deletions log/filter_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package log

import (
"os"
"path/filepath"
"regexp"
"testing"

"github.com/Laisky/zap"
"github.com/Laisky/zap/zapcore"
"github.com/stretchr/testify/require"
)

func TestFilter(t *testing.T) {
dir, err := os.MkdirTemp("", "TestWriteToFile*")
if err != nil {
t.Fatal(err)
}
t.Logf("create directory: %v", dir)
defer os.RemoveAll(dir)

file := filepath.Join(dir, "test.log")
logger, err := New(
WithOutputPaths([]string{file}),
WithZapOptions(
zap.Filter(func(e zapcore.Entry, f []zapcore.Field) bool {
return e.Message != "world"
}),
),
)
require.NoError(t, err)

logger.Info("hello")
logger.Info("beautiful")
logger.Info("world")
logger.Info("how")
logger.Info("are")
logger.Info("you")
_ = logger.Sync()

cntBytes, err := os.ReadFile(file)
content := string(cntBytes)
t.Logf("content:\n%s", content)
require.NoError(t, err)
require.Contains(t, content, "log/filter_test.go")
require.Contains(t, content, "hello\n")
require.NotContains(t, content, "world\n")
require.Len(t, regexp.MustCompile(`hello`).FindAllString(content, -1), 1)
}

0 comments on commit 34dbeb2

Please sign in to comment.