Skip to content

Commit 02a1c59

Browse files
authored
Merge pull request #6 from geofffranks/ginkgo-v2-lager-v3
* Make this a go module with vendored dependencies * Update to ginkgo v2 + lager v3 * Rename `Entry()` to `LogEntry()`
2 parents 9583333 + 21ef5c2 commit 02a1c59

File tree

682 files changed

+420365
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

682 files changed

+420365
-45
lines changed

example_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package glager_test
33
import (
44
"errors"
55

6-
"code.cloudfoundry.org/lager"
6+
"code.cloudfoundry.org/lager/v3"
77

8-
. "github.com/onsi/ginkgo"
8+
. "github.com/onsi/ginkgo/v2"
99
. "github.com/onsi/gomega"
1010
"github.com/onsi/gomega/gbytes"
1111

glager.go

+42-40
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"fmt"
1111
"io"
1212

13-
"code.cloudfoundry.org/lager"
13+
"code.cloudfoundry.org/lager/v3"
1414
"github.com/onsi/gomega/format"
1515
"github.com/onsi/gomega/gbytes"
1616
"github.com/onsi/gomega/types"
@@ -63,25 +63,26 @@ type logMatcher struct {
6363
// This matcher works best when used with a TestLogger.
6464
//
6565
// Example:
66-
// // instantiate glager.TestLogger inside your test and
67-
// logger := NewLogger("test")
6866
//
69-
// // pass it to your code and use it in there to log stuff
70-
// myFunc(logger)
67+
// // instantiate glager.TestLogger inside your test and
68+
// logger := NewLogger("test")
7169
//
72-
// // verify logging inside your test, using the logger
73-
// // in this example we are interested in the log level, the message, and the
74-
// // data of the log entries
75-
// Expect(logger).To(HaveLogged(
76-
// Info(
77-
// Message("test.myFunc"),
78-
// Data("event", "start"),
79-
// ),
80-
// Info(
81-
// Message("test.myFunc"),
82-
// Data("event", "done"),
83-
// ),
84-
// ))
70+
// // pass it to your code and use it in there to log stuff
71+
// myFunc(logger)
72+
//
73+
// // verify logging inside your test, using the logger
74+
// // in this example we are interested in the log level, the message, and the
75+
// // data of the log entries
76+
// Expect(logger).To(HaveLogged(
77+
// Info(
78+
// Message("test.myFunc"),
79+
// Data("event", "start"),
80+
// ),
81+
// Info(
82+
// Message("test.myFunc"),
83+
// Data("event", "done"),
84+
// ),
85+
// ))
8586
func HaveLogged(expectedSequence ...logEntry) types.GomegaMatcher {
8687
return ContainSequence(expectedSequence...)
8788
}
@@ -98,24 +99,25 @@ func HaveLogged(expectedSequence ...logEntry) types.GomegaMatcher {
9899
// This matcher works best when used with a Buffer.
99100
//
100101
// Example:
101-
// // instantiate regular lager logger and register buffer as sink
102-
// log := gbytes.NewBuffer()
103-
// logger := lager.NewLogger("test")
104-
// logger.RegisterSink(lager.NewWriterSink(log, lager.DEBUG))
105102
//
106-
// // pass it to your code and use it in there to log stuff
107-
// myFunc(logger)
103+
// // instantiate regular lager logger and register buffer as sink
104+
// log := gbytes.NewBuffer()
105+
// logger := lager.NewLogger("test")
106+
// logger.RegisterSink(lager.NewWriterSink(log, lager.DEBUG))
107+
//
108+
// // pass it to your code and use it in there to log stuff
109+
// myFunc(logger)
108110
//
109-
// // verify logging inside your test, using the log buffer
110-
// // in this example we are only interested in the data of the log entries
111-
// Expect(log).To(ContainSequence(
112-
// Info(
113-
// Data("event", "start"),
114-
// ),
115-
// Info(
116-
// Data("event", "done"),
117-
// ),
118-
// ))
111+
// // verify logging inside your test, using the log buffer
112+
// // in this example we are only interested in the data of the log entries
113+
// Expect(log).To(ContainSequence(
114+
// Info(
115+
// Data("event", "start"),
116+
// ),
117+
// Info(
118+
// Data("event", "done"),
119+
// ),
120+
// ))
119121
func ContainSequence(expectedSequence ...logEntry) types.GomegaMatcher {
120122
return &logMatcher{
121123
expected: expectedSequence,
@@ -125,13 +127,13 @@ func ContainSequence(expectedSequence ...logEntry) types.GomegaMatcher {
125127
// Info returns a log entry of type lager.INFO that can be used with the
126128
// HaveLogged and ContainSequence matchers.
127129
func Info(options ...option) logEntry {
128-
return Entry(lager.INFO, options...)
130+
return LogEntry(lager.INFO, options...)
129131
}
130132

131133
// Debug returns a log entry of type lager.DEBUG that can be used with the
132134
// HaveLogged and ContainSequence matchers.
133135
func Debug(options ...option) logEntry {
134-
return Entry(lager.DEBUG, options...)
136+
return LogEntry(lager.DEBUG, options...)
135137
}
136138

137139
// AnyErr can be used to check of arbitrary errors when matching Error entries.
@@ -144,7 +146,7 @@ func Error(err error, options ...option) logEntry {
144146
options = append(options, Data("error", err.Error()))
145147
}
146148

147-
return Entry(lager.ERROR, options...)
149+
return LogEntry(lager.ERROR, options...)
148150
}
149151

150152
// Fatal returns a log entry of type lager.FATAL that can be used with the
@@ -154,12 +156,12 @@ func Fatal(err error, options ...option) logEntry {
154156
options = append(options, Data("error", err.Error()))
155157
}
156158

157-
return Entry(lager.FATAL, options...)
159+
return LogEntry(lager.FATAL, options...)
158160
}
159161

160-
// Entry returns a log entry for the specified log level that can be used with
162+
// LogEntry returns a log entry for the specified log level that can be used with
161163
// the HaveLogged and ContainSequence matchers.
162-
func Entry(logLevel lager.LogLevel, options ...option) logEntry {
164+
func LogEntry(logLevel lager.LogLevel, options ...option) logEntry {
163165
entry := logEntry(lager.LogFormat{
164166
LogLevel: logLevel,
165167
Data: lager.Data{},

glager_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
"strings"
99
"testing"
1010

11-
"code.cloudfoundry.org/lager"
12-
"code.cloudfoundry.org/lager/lagertest"
11+
"code.cloudfoundry.org/lager/v3"
12+
"code.cloudfoundry.org/lager/v3/lagertest"
1313

14-
. "github.com/onsi/ginkgo"
14+
. "github.com/onsi/ginkgo/v2"
1515
. "github.com/onsi/gomega"
1616
"github.com/onsi/gomega/gbytes"
1717
"github.com/onsi/gomega/types"

go.mod

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module github.com/st3v/glager
2+
3+
go 1.20
4+
5+
require (
6+
code.cloudfoundry.org/lager/v3 v3.0.1
7+
github.com/onsi/ginkgo/v2 v2.9.2
8+
github.com/onsi/gomega v1.27.5
9+
)
10+
11+
require (
12+
github.com/go-logr/logr v1.2.3 // indirect
13+
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
14+
github.com/google/go-cmp v0.5.9 // indirect
15+
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
16+
github.com/openzipkin/zipkin-go v0.4.1 // indirect
17+
golang.org/x/net v0.8.0 // indirect
18+
golang.org/x/sys v0.6.0 // indirect
19+
golang.org/x/text v0.8.0 // indirect
20+
golang.org/x/tools v0.7.0 // indirect
21+
gopkg.in/yaml.v3 v3.0.1 // indirect
22+
)

go.sum

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
code.cloudfoundry.org/lager/v3 v3.0.1 h1:AI7h0EgCa4bJCCq0N8JV8EBP+tbJUIovqKc4hB4wZsA=
2+
code.cloudfoundry.org/lager/v3 v3.0.1/go.mod h1:zA6tOIWhr5uZUez+PGpdfBHDWQOfhOrr0cgKDagZPwk=
3+
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
4+
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
5+
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
6+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
8+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9+
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
10+
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
11+
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
12+
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
13+
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
14+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
15+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
16+
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
17+
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
18+
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
19+
github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU=
20+
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
21+
github.com/onsi/gomega v1.27.5 h1:T/X6I0RNFw/kTqgfkZPcQ5KU6vCnWNBGdtrIx2dpGeQ=
22+
github.com/onsi/gomega v1.27.5/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
23+
github.com/openzipkin/zipkin-go v0.4.1 h1:kNd/ST2yLLWhaWrkgchya40TJabe8Hioj9udfPcEO5A=
24+
github.com/openzipkin/zipkin-go v0.4.1/go.mod h1:qY0VqDSN1pOBN94dBc6w2GJlWLiovAyg7Qt6/I9HecM=
25+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
26+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
27+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
28+
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
29+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
30+
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
31+
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
32+
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
33+
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
34+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
35+
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
36+
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
37+
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
38+
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
39+
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
40+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
41+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
42+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
43+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
44+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

vendor/code.cloudfoundry.org/lager/v3/.gitignore

+38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)