File tree 2 files changed +13
-6
lines changed
2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,13 @@ import (
8
8
)
9
9
10
10
func Test_GetChain (t * testing.T ) {
11
- cli := NewClientWithLogger (testnetEndpoint , SimpleStdoutLogger {} )
11
+ cli := NewClientWithLogger (testnetEndpoint , SimpleLogger )
12
12
_ , err := cli .GetChain (context .Background (), GetChainOption {Simple : true })
13
13
assert .NoError (t , err )
14
14
}
15
15
16
16
func Test_GetLatestBlockHeight (t * testing.T ) {
17
- cli := NewClientWithLogger (testnetEndpoint , SimpleStdoutLogger {} )
17
+ cli := NewClientWithLogger (testnetEndpoint , SimpleLogger )
18
18
h , err := cli .GetLatestBlockHeight (context .Background ())
19
19
assert .NoError (t , err )
20
20
fmt .Printf ("%d\n " , h )
Original file line number Diff line number Diff line change @@ -2,15 +2,22 @@ package fuel
2
2
3
3
import (
4
4
"fmt"
5
- "time"
5
+ "log"
6
+ "os"
6
7
)
7
8
8
9
type Logger interface {
9
10
Infof (template string , args ... any )
10
11
}
11
12
12
- type SimpleStdoutLogger struct {}
13
+ type simpleLogger log. Logger
13
14
14
- func (l SimpleStdoutLogger ) Infof (template string , args ... any ) {
15
- fmt .Printf (time .Now ().String ()+ " " + template + "\n " , args ... )
15
+ func (l * simpleLogger ) Infof (template string , args ... any ) {
16
+ _ = (* log .Logger )(l ).Output (2 , fmt .Sprintf (template + "\n " , args ... ))
17
+ }
18
+
19
+ var SimpleLogger * simpleLogger
20
+
21
+ func init () {
22
+ SimpleLogger = (* simpleLogger )(log .New (os .Stdout , "" , log .Ldate | log .Ltime | log .Lmicroseconds | log .Lshortfile ))
16
23
}
You can’t perform that action at this time.
0 commit comments