Skip to content

Commit ff242a8

Browse files
committed
Remove skipctx pkg
Don't need it.
1 parent cb6d07e commit ff242a8

File tree

4 files changed

+13
-29
lines changed

4 files changed

+13
-29
lines changed

internal/skipctx/skipctx.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

slog.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"time"
1010

1111
"go.opencensus.io/trace"
12-
13-
"go.coder.com/slog/internal/skipctx"
1412
)
1513

1614
// Field represents a log field.
@@ -157,6 +155,7 @@ func Make(s Sink) Logger {
157155
},
158156
},
159157
testingHelper: func() {},
158+
skip: 2,
160159
}
161160
l.SetLevel(LevelDebug)
162161

@@ -178,6 +177,7 @@ type Logger struct {
178177
testingHelper func()
179178

180179
sinks []sink
180+
skip int
181181
}
182182

183183
func (l Logger) Debug(ctx context.Context, msg string, fields ...Field) {
@@ -239,7 +239,7 @@ func (l Logger) log(ctx context.Context, level Level, msg string, fields []Field
239239
level: level,
240240
msg: msg,
241241
fields: fields,
242-
skip: 2,
242+
skip: l.skip,
243243
})
244244

245245
s.sink.LogEntry(ctx, ent)
@@ -324,7 +324,7 @@ func (l parsedFields) entry(ctx context.Context, params entryParams) Entry {
324324
Fields: l.fields,
325325
}
326326

327-
file, line, fn, ok := location(params.skip + 1 + skipctx.From(ctx))
327+
file, line, fn, ok := location(params.skip + 1)
328328
if ok {
329329
ent.File = file
330330
ent.Line = line

sloggers/slogtest/test_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package slogtest_test
22

33
import (
4+
"context"
45
"io"
56
"strconv"
67
"testing"
@@ -43,4 +44,10 @@ func TestExampleTest(t *testing.T) {
4344
meow{3},
4445
)),
4546
)
47+
48+
l := slogtest.Make(t, nil).With(
49+
slog.F("hi", "anmol"),
50+
)
51+
stdlibLog := slog.Stdlib(context.Background(), l)
52+
stdlibLog.Println("stdlib")
4653
}

stdlib.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"log"
66
"strings"
77

8-
"go.coder.com/slog/internal/skipctx"
98
"go.coder.com/slog/internal/stdlibctx"
109
)
1110

@@ -19,7 +18,8 @@ import (
1918
// to the Writer on the logger returned by this function.
2019
// See the example.
2120
func Stdlib(ctx context.Context, l Logger) *log.Logger {
22-
ctx = skipctx.With(ctx, 4)
21+
l.skip += 4
22+
2323
ctx = stdlibctx.With(ctx)
2424

2525
w := &stdlogWriter{

0 commit comments

Comments
 (0)