File tree Expand file tree Collapse file tree 10 files changed +2026
-1
lines changed
Expand file tree Collapse file tree 10 files changed +2026
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ linters:
1414 - ineffassign
1515 - makezero
1616 - nilerr
17- - paralleltest
17+ # - paralleltest # Reference: https://github.com/kunwardeep/paralleltest/issues/14
1818 - predeclared
1919 - staticcheck
2020 # - tenv # TODO: Enable when upgrading Go 1.16 to 1.17
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module github.com/hashicorp/terraform-plugin-log
33go 1.16
44
55require (
6+ github.com/google/go-cmp v0.5.7
67 github.com/hashicorp/go-hclog v1.1.0
78 github.com/mitchellh/go-testing-interface v1.14.1
89 github.com/stretchr/testify v1.3.0 // indirect
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
33github.com/davecgh/go-spew v1.1.1 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
44github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys =
55github.com/fatih/color v1.7.0 /go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4 =
6+ github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o =
7+ github.com/google/go-cmp v0.5.7 /go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE =
68github.com/hashicorp/go-hclog v1.1.0 h1:QsGcniKx5/LuX2eYoeL+Np3UKYPNaN7YKpTh29h8rbw =
79github.com/hashicorp/go-hclog v1.1.0 /go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ =
810github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA =
@@ -21,3 +23,5 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
2123golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 /go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY =
2224golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9YmqEm0diQn9QmZw/0mU =
2325golang.org/x/sys v0.0.0-20191008105621-543471e840be /go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs =
26+ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4 =
27+ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 /go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0 =
Original file line number Diff line number Diff line change 1+ package loggertest
2+
3+ import (
4+ "encoding/json"
5+ "fmt"
6+ "io"
7+ )
8+
9+ func MultilineJSONDecode (data io.Reader ) ([]map [string ]interface {}, error ) {
10+ var result []map [string ]interface {}
11+ var entry map [string ]interface {}
12+
13+ dec := json .NewDecoder (data )
14+
15+ for {
16+ err := dec .Decode (& entry )
17+
18+ if err == io .EOF {
19+ break
20+ }
21+
22+ if err != nil {
23+ return result , fmt .Errorf ("unable to decode JSON: %s" , err )
24+ }
25+
26+ result = append (result , entry )
27+ }
28+
29+ return result , nil
30+ }
Original file line number Diff line number Diff line change 1+ package loggertest
2+
3+ import (
4+ "context"
5+ "io"
6+
7+ "github.com/hashicorp/go-hclog"
8+ "github.com/hashicorp/terraform-plugin-log/internal/logging"
9+ )
10+
11+ func ProviderRoot (ctx context.Context , output io.Writer ) context.Context {
12+ loggerOptions := & hclog.LoggerOptions {
13+ DisableTime : true ,
14+ JSONFormat : true ,
15+ Level : hclog .Trace ,
16+ Output : output ,
17+ }
18+
19+ ctx = logging .SetProviderRootLogger (ctx , hclog .New (loggerOptions ))
20+
21+ return ctx
22+ }
Original file line number Diff line number Diff line change 1+ package loggertest
2+
3+ import (
4+ "context"
5+ "io"
6+
7+ "github.com/hashicorp/go-hclog"
8+ "github.com/hashicorp/terraform-plugin-log/internal/logging"
9+ )
10+
11+ func SDKRoot (ctx context.Context , output io.Writer ) context.Context {
12+ loggerOptions := & hclog.LoggerOptions {
13+ DisableTime : true ,
14+ JSONFormat : true ,
15+ Level : hclog .Trace ,
16+ Output : output ,
17+ }
18+
19+ ctx = logging .SetSDKRootLogger (ctx , hclog .New (loggerOptions ))
20+
21+ return ctx
22+ }
You can’t perform that action at this time.
0 commit comments