Skip to content

Commit 10d9ae0

Browse files
committed
ignore coverage
1 parent b4360c9 commit 10d9ae0

File tree

4 files changed

+102
-57
lines changed

4 files changed

+102
-57
lines changed

.codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ coverage:
1111
default:
1212
# Do not fail the commit status if the coverage was reduced up to this value
1313
threshold: 0.5%
14+
ignore:
15+
- "log_fallback.go"

log.go

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package sentry
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
"os"
87
"strings"
@@ -207,59 +206,3 @@ func (l *sentryLogger) Panicf(ctx context.Context, format string, v ...interface
207206
l.log(ctx, LogLevelFatal, LogSeverityFatal, format, v...)
208207
panic(fmt.Sprint(v...))
209208
}
210-
211-
// fallback no-op logger if Sentry is not enabled.
212-
type noopLogger struct{}
213-
214-
func (*noopLogger) Trace(_ context.Context, _ ...interface{}) {
215-
DebugLogger.Println("does nothing: EnableLogs disabled")
216-
}
217-
func (*noopLogger) Debug(_ context.Context, _ ...interface{}) {
218-
DebugLogger.Println("does nothing: EnableLogs disabled")
219-
}
220-
func (*noopLogger) Info(_ context.Context, _ ...interface{}) {
221-
DebugLogger.Println("does nothing: EnableLogs disabled")
222-
}
223-
func (*noopLogger) Warn(_ context.Context, _ ...interface{}) {
224-
DebugLogger.Println("does nothing: EnableLogs disabled")
225-
}
226-
func (*noopLogger) Error(_ context.Context, _ ...interface{}) {
227-
DebugLogger.Println("does nothing: EnableLogs disabled")
228-
}
229-
func (*noopLogger) Fatal(_ context.Context, _ ...interface{}) {
230-
DebugLogger.Println("does nothing: EnableLogs disabled")
231-
os.Exit(1)
232-
}
233-
func (*noopLogger) Panic(_ context.Context, _ ...interface{}) {
234-
DebugLogger.Println("does nothing: EnableLogs disabled")
235-
panic("invalid setup: EnableLogs disabled")
236-
}
237-
func (*noopLogger) Tracef(_ context.Context, _ string, _ ...interface{}) {
238-
DebugLogger.Println("does nothing: EnableLogs disabled")
239-
}
240-
func (*noopLogger) Debugf(_ context.Context, _ string, _ ...interface{}) {
241-
DebugLogger.Println("does nothing: EnableLogs disabled")
242-
}
243-
func (*noopLogger) Infof(_ context.Context, _ string, _ ...interface{}) {
244-
DebugLogger.Println("does nothing: EnableLogs disabled")
245-
}
246-
func (*noopLogger) Warnf(_ context.Context, _ string, _ ...interface{}) {
247-
DebugLogger.Println("does nothing: EnableLogs disabled")
248-
}
249-
func (*noopLogger) Errorf(_ context.Context, _ string, _ ...interface{}) {
250-
DebugLogger.Println("does nothing: EnableLogs disabled")
251-
}
252-
func (*noopLogger) Fatalf(_ context.Context, _ string, _ ...interface{}) {
253-
DebugLogger.Println("does nothing: EnableLogs disabled")
254-
os.Exit(1)
255-
}
256-
func (*noopLogger) Panicf(_ context.Context, _ string, _ ...interface{}) {
257-
DebugLogger.Println("does nothing: EnableLogs disabled")
258-
panic("invalid setup: EnableLogs disabled")
259-
}
260-
func (*noopLogger) SetAttributes(...attribute.Builder) {
261-
DebugLogger.Println("does nothing: EnableLogs disabled")
262-
}
263-
func (*noopLogger) Write(_ []byte) (n int, err error) {
264-
return 0, errors.New("does nothing: EnableLogs disabled")
265-
}

log_fallback.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package sentry
2+
3+
import (
4+
"context"
5+
"errors"
6+
"os"
7+
8+
"github.com/getsentry/sentry-go/attribute"
9+
)
10+
11+
// fallback no-op logger if Sentry is not enabled.
12+
type noopLogger struct{}
13+
14+
func (*noopLogger) Trace(_ context.Context, _ ...interface{}) {
15+
DebugLogger.Println("does nothing: EnableLogs disabled")
16+
}
17+
func (*noopLogger) Debug(_ context.Context, _ ...interface{}) {
18+
DebugLogger.Println("does nothing: EnableLogs disabled")
19+
}
20+
func (*noopLogger) Info(_ context.Context, _ ...interface{}) {
21+
DebugLogger.Println("does nothing: EnableLogs disabled")
22+
}
23+
func (*noopLogger) Warn(_ context.Context, _ ...interface{}) {
24+
DebugLogger.Println("does nothing: EnableLogs disabled")
25+
}
26+
func (*noopLogger) Error(_ context.Context, _ ...interface{}) {
27+
DebugLogger.Println("does nothing: EnableLogs disabled")
28+
}
29+
func (*noopLogger) Fatal(_ context.Context, _ ...interface{}) {
30+
DebugLogger.Println("does nothing: EnableLogs disabled")
31+
os.Exit(1)
32+
}
33+
func (*noopLogger) Panic(_ context.Context, _ ...interface{}) {
34+
DebugLogger.Println("does nothing: EnableLogs disabled")
35+
panic("invalid setup: EnableLogs disabled")
36+
}
37+
func (*noopLogger) Tracef(_ context.Context, _ string, _ ...interface{}) {
38+
DebugLogger.Println("does nothing: EnableLogs disabled")
39+
}
40+
func (*noopLogger) Debugf(_ context.Context, _ string, _ ...interface{}) {
41+
DebugLogger.Println("does nothing: EnableLogs disabled")
42+
}
43+
func (*noopLogger) Infof(_ context.Context, _ string, _ ...interface{}) {
44+
DebugLogger.Println("does nothing: EnableLogs disabled")
45+
}
46+
func (*noopLogger) Warnf(_ context.Context, _ string, _ ...interface{}) {
47+
DebugLogger.Println("does nothing: EnableLogs disabled")
48+
}
49+
func (*noopLogger) Errorf(_ context.Context, _ string, _ ...interface{}) {
50+
DebugLogger.Println("does nothing: EnableLogs disabled")
51+
}
52+
func (*noopLogger) Fatalf(_ context.Context, _ string, _ ...interface{}) {
53+
DebugLogger.Println("does nothing: EnableLogs disabled")
54+
os.Exit(1)
55+
}
56+
func (*noopLogger) Panicf(_ context.Context, _ string, _ ...interface{}) {
57+
DebugLogger.Println("does nothing: EnableLogs disabled")
58+
panic("invalid setup: EnableLogs disabled")
59+
}
60+
func (*noopLogger) SetAttributes(...attribute.Builder) {
61+
DebugLogger.Println("does nothing: EnableLogs disabled")
62+
}
63+
func (*noopLogger) Write(_ []byte) (n int, err error) {
64+
return 0, errors.New("does nothing: EnableLogs disabled")
65+
}

transport_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,41 @@ func TestEnvelopeFromCheckInEvent(t *testing.T) {
260260
}
261261
}
262262

263+
func TestEnvelopeFromLogEvent(t *testing.T) {
264+
event := newTestEvent(logType)
265+
event.Logs = []Log{
266+
{
267+
TraceID: TraceIDFromHex(LogTraceID),
268+
Level: LogLevelInfo,
269+
Severity: LogSeverityInfo,
270+
Body: "test log message",
271+
Attributes: map[string]Attribute{
272+
"sentry.release": {Value: "v1.2.3", Type: "string"},
273+
"sentry.environment": {Value: "testing", Type: "string"},
274+
"sentry.server.address": {Value: "test-server", Type: "string"},
275+
"sentry.sdk.name": {Value: "sentry.go", Type: "string"},
276+
"sentry.sdk.version": {Value: "0.0.1", Type: "string"},
277+
"sentry.origin": {Value: "auto.logger.log", Type: "string"},
278+
},
279+
},
280+
}
281+
sentAt := time.Unix(0, 0).UTC()
282+
283+
body := getRequestBodyFromEvent(event)
284+
b, err := envelopeFromBody(event, newTestDSN(t), sentAt, body)
285+
if err != nil {
286+
t.Fatal(err)
287+
}
288+
got := b.String()
289+
want := `{"event_id":"b81c5be4d31e48959103a1f878a1efcb","sent_at":"1970-01-01T00:00:00Z","dsn":"http://public@example.com/sentry/1","sdk":{"name":"sentry.go","version":"0.0.1"}}
290+
{"type":"log","item_count":1,"content_type":"application/vnd.sentry.items.log+json"}
291+
{"event_id":"b81c5be4d31e48959103a1f878a1efcb","sdk":{"name":"sentry.go","version":"0.0.1"},"user":{},"items":[{"timestamp":"0001-01-01T00:00:00Z","trace_id":"d49d9bf66f13450b81f65bc51cf49c03","level":"info","severity_number":9,"body":"test log message","attributes":{"sentry.environment":{"value":"testing","type":"string"},"sentry.origin":{"value":"auto.logger.log","type":"string"},"sentry.release":{"value":"v1.2.3","type":"string"},"sentry.sdk.name":{"value":"sentry.go","type":"string"},"sentry.sdk.version":{"value":"0.0.1","type":"string"},"sentry.server.address":{"value":"test-server","type":"string"}}}]}
292+
`
293+
if diff := cmp.Diff(want, got); diff != "" {
294+
t.Errorf("Envelope mismatch (-want +got):\n%s", diff)
295+
}
296+
}
297+
263298
func TestGetRequestFromEvent(t *testing.T) {
264299
testCases := []struct {
265300
testName string

0 commit comments

Comments
 (0)