Skip to content

Commit 1b2b513

Browse files
committed
callerSkip change
1 parent 51fd2fd commit 1b2b513

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,27 @@ select {}
2323

2424
```
2525

26-
## normal output
26+
## consoleWriter
2727

2828
```` go
2929
l := NewSpoor(DEBUG, "", log.Ldate|log.Ltime|log.Lmicroseconds|log.Llongfile, WithNormalWriter(os.Stdout))
3030
l.DebugF("hhhh")
31+
````
32+
## elasticWriter
33+
34+
````go
35+
36+
37+
````
38+
## clickHouseWriter
39+
40+
````go
41+
42+
43+
````
44+
## logbusWriter
45+
46+
````go
47+
48+
3149
````

spoor.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func WithFileWriter(writer *FileWriter) Option {
2222
}
2323
}
2424

25-
func WithNormalWriter(writer io.Writer) Option {
25+
func WithConsoleWriter(writer io.Writer) Option {
2626
return func(spoor *Spoor) {
2727
spoor.l.SetOutput(writer)
2828
}
@@ -45,28 +45,28 @@ func (s *Spoor) DebugF(f string, args ...interface{}) {
4545
if s.checkLevel(DEBUG) {
4646
return
4747
}
48-
s.l.Output(3, fmt.Sprintf(DEBUG.String()+" "+f, args...))
48+
s.l.Output(2, fmt.Sprintf(DEBUG.String()+" "+f, args...))
4949
}
5050

5151
func (s *Spoor) ErrorF(f string, args ...interface{}) {
5252
if s.checkLevel(ERROR) {
5353
return
5454
}
55-
s.l.Output(3, fmt.Sprintf(ERROR.String()+" "+f, args...))
55+
s.l.Output(2, fmt.Sprintf(ERROR.String()+" "+f, args...))
5656
}
5757

5858
func (s *Spoor) InfoF(f string, args ...interface{}) {
5959
if s.checkLevel(INFO) {
6060
return
6161
}
62-
s.l.Output(3, fmt.Sprintf(INFO.String()+" "+f, args...))
62+
s.l.Output(2, fmt.Sprintf(INFO.String()+" "+f, args...))
6363
}
6464

6565
func (s *Spoor) FatalF(f string, args ...interface{}) {
6666
if s.checkLevel(FATAL) {
6767
return
6868
}
69-
s.l.Output(3, fmt.Sprintf(FATAL.String()+" "+f, args...))
69+
s.l.Output(2, fmt.Sprintf(FATAL.String()+" "+f, args...))
7070
}
7171

7272
func (l *Spoor) checkLevel(level Level) bool {

spoor_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
package spoor
22

33
import (
4+
"fmt"
45
"log"
56
"os"
7+
"runtime"
68
"testing"
79
)
810

911
func TestName(t *testing.T) {
10-
l := NewSpoor(DEBUG, "", log.Ldate|log.Ltime|log.Lmicroseconds|log.Llongfile, WithNormalWriter(os.Stdout))
12+
l := NewSpoor(DEBUG, "", log.Ldate|log.Ltime|log.Lmicroseconds|log.Llongfile, WithConsoleWriter(os.Stdout))
1113
l.DebugF("hhhh")
14+
l.InfoF("jjjjj")
1215
}
1316

1417
func TestFileWriter(t *testing.T) {
15-
fileWriter := NewFileWriter(".", 0, 0, 0)
18+
fileWriter := NewFileWriter("log", 0, 0, 0)
1619
l := NewSpoor(DEBUG, "", log.Ldate|log.Ltime|log.Lmicroseconds|log.Llongfile, WithFileWriter(fileWriter))
1720
l.DebugF("hhhh")
1821
select {}
1922

2023
}
24+
25+
func TestName1(t *testing.T) {
26+
_, file, line, ok := runtime.Caller(-1)
27+
fmt.Println(file, line, ok)
28+
29+
}

0 commit comments

Comments
 (0)