forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
26 lines (22 loc) · 766 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Package test contains simple test helpers that should not
// have any service-specific dependencies.
// think constants, custom matchers, generic helpers etc.
package test
import (
"bytes"
"context"
"github.com/sirupsen/logrus"
"github.com/stellar/go/support/log"
)
// ContextWithLogBuffer returns a context and a buffer into which the new, bound
// logger will write into. This method allows you to inspect what data was
// logged more easily in your tests.
func ContextWithLogBuffer() (context.Context, *bytes.Buffer) {
output := new(bytes.Buffer)
l := log.New()
l.Logger.Out = output
l.Logger.Formatter.(*logrus.TextFormatter).DisableColors = true
l.Logger.Level = logrus.DebugLevel
ctx := log.Set(context.Background(), l)
return ctx, output
}