File tree 3 files changed +13
-19
lines changed
3 files changed +13
-19
lines changed Original file line number Diff line number Diff line change @@ -11,16 +11,12 @@ import (
11
11
"go.coder.com/slog/slogcore"
12
12
)
13
13
14
- func Stderr () Logger {
15
- return Make (HumanSink (os .Stderr ))
16
- }
17
-
18
- type writerSink struct {
14
+ type humanSink struct {
19
15
mu sync.Mutex
20
16
w io.Writer
21
17
}
22
18
23
- func (w * writerSink ) WriteLogEntry (ent slogcore.Entry ) {
19
+ func (w * humanSink ) WriteLogEntry (ent slogcore.Entry ) {
24
20
s := humanfmt .Entry (ent )
25
21
lines := strings .Split (s , "\n " )
26
22
@@ -37,28 +33,28 @@ func (w *writerSink) WriteLogEntry(ent slogcore.Entry) {
37
33
w .writeString (s + "\n " )
38
34
}
39
35
40
- func (w * writerSink ) writeString (s string ) {
36
+ func (w * humanSink ) writeString (s string ) {
41
37
w .mu .Lock ()
42
38
defer w .mu .Unlock ()
43
39
44
40
io .WriteString (w .w , s )
45
41
}
46
42
47
- func HumanSink (w io.Writer ) Sink {
48
- return & writerSink {
43
+ func Human (w io.Writer ) Logger {
44
+ return Make ( & humanSink {
49
45
w : w ,
50
- }
46
+ })
51
47
}
52
48
53
49
// Make creates a logger that writes logs to sink.
54
- func Make (sink Sink ) Logger {
50
+ func Make (sink slogcore. Sink ) Logger {
55
51
return logger {
56
52
sink : sink ,
57
53
}
58
54
}
59
55
60
56
type logger struct {
61
- sink Sink
57
+ sink slogcore. Sink
62
58
l parsedFields
63
59
}
64
60
Original file line number Diff line number Diff line change @@ -2,15 +2,8 @@ package slog
2
2
3
3
import (
4
4
"context"
5
-
6
- "go.coder.com/slog/slogcore"
7
5
)
8
6
9
- // Sink is the destination of a Logger.
10
- type Sink interface {
11
- WriteLogEntry (e slogcore.Entry )
12
- }
13
-
14
7
// Logger is the core interface for logging.
15
8
type Logger interface {
16
9
// Debug means a potentially noisy log.
Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ import (
8
8
"go.opencensus.io/trace"
9
9
)
10
10
11
+ // Sink is the destination of a Logger.
12
+ type Sink interface {
13
+ WriteLogEntry (e Entry )
14
+ }
15
+
11
16
type Level string
12
17
13
18
const (
You can’t perform that action at this time.
0 commit comments