Skip to content

Commit 64de096

Browse files
authored
Rename Logger to DebugLogger (#1012)
1 parent 523e1b4 commit 64de096

File tree

12 files changed

+58
-58
lines changed

12 files changed

+58
-58
lines changed

_examples/http/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ func NewImage(ctx context.Context, width, height int, seed []byte) image.Image {
264264
// The only reason to change logger configuration in this example is aesthetics.
265265
func configureLoggers() {
266266
logFlags := log.Ldate | log.Ltime
267-
sentry.Logger.SetPrefix("[sentry sdk] ")
268-
sentry.Logger.SetFlags(logFlags)
267+
sentry.DebugLogger.SetPrefix("[sentry sdk] ")
268+
sentry.DebugLogger.SetFlags(logFlags)
269269
log.SetPrefix("[http example] ")
270270
log.SetFlags(logFlags)
271271
}

client.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ type usageError struct {
7777
error
7878
}
7979

80-
// Logger is an instance of log.Logger that is use to provide debug information about running Sentry Client
81-
// can be enabled by either using Logger.SetOutput directly or with Debug client option.
82-
var Logger = log.New(io.Discard, "[Sentry] ", log.LstdFlags)
80+
// DebugLogger is an instance of log.Logger that is used to provide debug information about running Sentry Client
81+
// can be enabled by either using DebugLogger.SetOutput directly or with Debug client option.
82+
var DebugLogger = log.New(io.Discard, "[Sentry] ", log.LstdFlags)
8383

8484
// EventProcessor is a function that processes an event.
8585
// Event processors are used to change an event before it is sent to Sentry.
@@ -275,7 +275,7 @@ func NewClient(options ClientOptions) (*Client, error) {
275275
if debugWriter == nil {
276276
debugWriter = os.Stderr
277277
}
278-
Logger.SetOutput(debugWriter)
278+
DebugLogger.SetOutput(debugWriter)
279279
}
280280

281281
if options.Dsn == "" {
@@ -383,12 +383,12 @@ func (client *Client) setupIntegrations() {
383383

384384
for _, integration := range integrations {
385385
if client.integrationAlreadyInstalled(integration.Name()) {
386-
Logger.Printf("Integration %s is already installed\n", integration.Name())
386+
DebugLogger.Printf("Integration %s is already installed\n", integration.Name())
387387
continue
388388
}
389389
client.integrations = append(client.integrations, integration)
390390
integration.SetupOnce(client)
391-
Logger.Printf("Integration installed: %s\n", integration.Name())
391+
DebugLogger.Printf("Integration installed: %s\n", integration.Name())
392392
}
393393

394394
sort.Slice(client.integrations, func(i, j int) bool {
@@ -605,7 +605,7 @@ func (client *Client) processEvent(event *Event, hint *EventHint, scope EventMod
605605
// options.TracesSampler when they are started. Other events
606606
// (errors, messages) are sampled here. Does not apply to check-ins.
607607
if event.Type != transactionType && event.Type != checkInType && !sample(client.options.SampleRate) {
608-
Logger.Println("Event dropped due to SampleRate hit.")
608+
DebugLogger.Println("Event dropped due to SampleRate hit.")
609609
return nil
610610
}
611611

@@ -620,13 +620,13 @@ func (client *Client) processEvent(event *Event, hint *EventHint, scope EventMod
620620
if event.Type == transactionType && client.options.BeforeSendTransaction != nil {
621621
// Transaction events
622622
if event = client.options.BeforeSendTransaction(event, hint); event == nil {
623-
Logger.Println("Transaction dropped due to BeforeSendTransaction callback.")
623+
DebugLogger.Println("Transaction dropped due to BeforeSendTransaction callback.")
624624
return nil
625625
}
626626
} else if event.Type != transactionType && event.Type != checkInType && client.options.BeforeSend != nil {
627627
// All other events
628628
if event = client.options.BeforeSend(event, hint); event == nil {
629-
Logger.Println("Event dropped due to BeforeSend callback.")
629+
DebugLogger.Println("Event dropped due to BeforeSend callback.")
630630
return nil
631631
}
632632
}
@@ -692,7 +692,7 @@ func (client *Client) prepareEvent(event *Event, hint *EventHint, scope EventMod
692692
id := event.EventID
693693
event = processor(event, hint)
694694
if event == nil {
695-
Logger.Printf("Event dropped by one of the Client EventProcessors: %s\n", id)
695+
DebugLogger.Printf("Event dropped by one of the Client EventProcessors: %s\n", id)
696696
return nil
697697
}
698698
}
@@ -701,7 +701,7 @@ func (client *Client) prepareEvent(event *Event, hint *EventHint, scope EventMod
701701
id := event.EventID
702702
event = processor(event, hint)
703703
if event == nil {
704-
Logger.Printf("Event dropped by one of the Global EventProcessors: %s\n", id)
704+
DebugLogger.Printf("Event dropped by one of the Global EventProcessors: %s\n", id)
705705
return nil
706706
}
707707
}

fasthttp/sentryfasthttp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func GetSpanFromContext(ctx *fasthttp.RequestCtx) *sentry.Span {
143143
func convert(ctx *fasthttp.RequestCtx) *http.Request {
144144
defer func() {
145145
if err := recover(); err != nil {
146-
sentry.Logger.Printf("%v", err)
146+
sentry.DebugLogger.Printf("%v", err)
147147
}
148148
}()
149149

fiber/sentryfiber.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func GetSpanFromContext(ctx *fiber.Ctx) *sentry.Span {
143143
func convert(ctx *fiber.Ctx) *http.Request {
144144
defer func() {
145145
if err := recover(); err != nil {
146-
sentry.Logger.Printf("%v", err)
146+
sentry.DebugLogger.Printf("%v", err)
147147
}
148148
}()
149149

hub.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func (hub *Hub) AddBreadcrumb(breadcrumb *Breadcrumb, hint *BreadcrumbHint) {
308308
hint = &BreadcrumbHint{}
309309
}
310310
if breadcrumb = client.options.BeforeBreadcrumb(breadcrumb, hint); breadcrumb == nil {
311-
Logger.Println("breadcrumb dropped due to BeforeBreadcrumb callback.")
311+
DebugLogger.Println("breadcrumb dropped due to BeforeBreadcrumb callback.")
312312
return
313313
}
314314
}

integrations.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (mi *modulesIntegration) processor(event *Event, _ *EventHint) *Event {
3232
mi.once.Do(func() {
3333
info, ok := debug.ReadBuildInfo()
3434
if !ok {
35-
Logger.Print("The Modules integration is not available in binaries built without module support.")
35+
DebugLogger.Print("The Modules integration is not available in binaries built without module support.")
3636
return
3737
}
3838
mi.modules = extractModules(info)
@@ -141,7 +141,7 @@ func (iei *ignoreErrorsIntegration) processor(event *Event, _ *EventHint) *Event
141141
for _, suspect := range suspects {
142142
for _, pattern := range iei.ignoreErrors {
143143
if pattern.Match([]byte(suspect)) || strings.Contains(suspect, pattern.String()) {
144-
Logger.Printf("Event dropped due to being matched by `IgnoreErrors` option."+
144+
DebugLogger.Printf("Event dropped due to being matched by `IgnoreErrors` option."+
145145
"| Value matched: %s | Filter used: %s", suspect, pattern)
146146
return nil
147147
}
@@ -203,7 +203,7 @@ func (iei *ignoreTransactionsIntegration) processor(event *Event, _ *EventHint)
203203

204204
for _, pattern := range iei.ignoreTransactions {
205205
if pattern.Match([]byte(suspect)) || strings.Contains(suspect, pattern.String()) {
206-
Logger.Printf("Transaction dropped due to being matched by `IgnoreTransactions` option."+
206+
DebugLogger.Printf("Transaction dropped due to being matched by `IgnoreTransactions` option."+
207207
"| Value matched: %s | Filter used: %s", suspect, pattern)
208208
return nil
209209
}

scope.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint, client *Client)
464464
id := event.EventID
465465
event = processor(event, hint)
466466
if event == nil {
467-
Logger.Printf("Event dropped by one of the Scope EventProcessors: %s\n", id)
467+
DebugLogger.Printf("Event dropped by one of the Scope EventProcessors: %s\n", id)
468468
return nil
469469
}
470470
}

span_recorder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (r *spanRecorder) record(s *Span) {
2424
if len(r.spans) >= maxSpans {
2525
r.overflowOnce.Do(func() {
2626
root := r.spans[0]
27-
Logger.Printf("Too many spans: dropping spans from transaction with TraceID=%s SpanID=%s limit=%d",
27+
DebugLogger.Printf("Too many spans: dropping spans from transaction with TraceID=%s SpanID=%s limit=%d",
2828
root.TraceID, root.SpanID, maxSpans)
2929
})
3030
// TODO(tracing): mark the transaction event in some way to

span_recorder_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func Test_spanRecorder_record(t *testing.T) {
3232
} {
3333
t.Run(tt.name, func(t *testing.T) {
3434
logBuffer := bytes.Buffer{}
35-
Logger.SetOutput(&logBuffer)
36-
defer Logger.SetOutput(io.Discard)
35+
DebugLogger.SetOutput(&logBuffer)
36+
defer DebugLogger.SetOutput(io.Discard)
3737
spanRecorder := spanRecorder{}
3838

3939
currentHub.BindClient(&Client{
@@ -54,7 +54,7 @@ func Test_spanRecorder_record(t *testing.T) {
5454
} else {
5555
assertEqual(t, len(spanRecorder.spans), tt.toRecordSpans, "expected no overflow")
5656
}
57-
// check if Logger was called for overflow messages
57+
// check if DebugLogger was called for overflow messages
5858
if bytes.Contains(logBuffer.Bytes(), []byte("Too many spans")) && !tt.expectOverflow {
5959
t.Error("unexpected overflow log")
6060
}

tracing.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,14 @@ func (s *Span) sample() Sampled {
452452
// https://develop.sentry.dev/sdk/performance/#sampling
453453
// #1 tracing is not enabled.
454454
if !clientOptions.EnableTracing {
455-
Logger.Printf("Dropping transaction: EnableTracing is set to %t", clientOptions.EnableTracing)
455+
DebugLogger.Printf("Dropping transaction: EnableTracing is set to %t", clientOptions.EnableTracing)
456456
s.sampleRate = 0.0
457457
return SampledFalse
458458
}
459459

460460
// #2 explicit sampling decision via StartSpan/StartTransaction options.
461461
if s.explicitSampled != SampledUndefined {
462-
Logger.Printf("Using explicit sampling decision from StartSpan/StartTransaction: %v", s.explicitSampled)
462+
DebugLogger.Printf("Using explicit sampling decision from StartSpan/StartTransaction: %v", s.explicitSampled)
463463
switch s.explicitSampled {
464464
case SampledTrue:
465465
s.sampleRate = 1.0
@@ -492,25 +492,25 @@ func (s *Span) sample() Sampled {
492492
s.dynamicSamplingContext.Entries["sample_rate"] = strconv.FormatFloat(tracesSamplerSampleRate, 'f', -1, 64)
493493
}
494494
if tracesSamplerSampleRate < 0.0 || tracesSamplerSampleRate > 1.0 {
495-
Logger.Printf("Dropping transaction: Returned TracesSampler rate is out of range [0.0, 1.0]: %f", tracesSamplerSampleRate)
495+
DebugLogger.Printf("Dropping transaction: Returned TracesSampler rate is out of range [0.0, 1.0]: %f", tracesSamplerSampleRate)
496496
return SampledFalse
497497
}
498498
if tracesSamplerSampleRate == 0.0 {
499-
Logger.Printf("Dropping transaction: Returned TracesSampler rate is: %f", tracesSamplerSampleRate)
499+
DebugLogger.Printf("Dropping transaction: Returned TracesSampler rate is: %f", tracesSamplerSampleRate)
500500
return SampledFalse
501501
}
502502

503503
if rng.Float64() < tracesSamplerSampleRate {
504504
return SampledTrue
505505
}
506-
Logger.Printf("Dropping transaction: TracesSampler returned rate: %f", tracesSamplerSampleRate)
506+
DebugLogger.Printf("Dropping transaction: TracesSampler returned rate: %f", tracesSamplerSampleRate)
507507

508508
return SampledFalse
509509
}
510510

511511
// #4 inherit parent decision.
512512
if s.Sampled != SampledUndefined {
513-
Logger.Printf("Using sampling decision from parent: %v", s.Sampled)
513+
DebugLogger.Printf("Using sampling decision from parent: %v", s.Sampled)
514514
switch s.Sampled {
515515
case SampledTrue:
516516
s.sampleRate = 1.0
@@ -528,11 +528,11 @@ func (s *Span) sample() Sampled {
528528
s.dynamicSamplingContext.Entries["sample_rate"] = strconv.FormatFloat(sampleRate, 'f', -1, 64)
529529
}
530530
if sampleRate < 0.0 || sampleRate > 1.0 {
531-
Logger.Printf("Dropping transaction: TracesSampleRate out of range [0.0, 1.0]: %f", sampleRate)
531+
DebugLogger.Printf("Dropping transaction: TracesSampleRate out of range [0.0, 1.0]: %f", sampleRate)
532532
return SampledFalse
533533
}
534534
if sampleRate == 0.0 {
535-
Logger.Printf("Dropping transaction: TracesSampleRate rate is: %f", sampleRate)
535+
DebugLogger.Printf("Dropping transaction: TracesSampleRate rate is: %f", sampleRate)
536536
return SampledFalse
537537
}
538538

@@ -555,7 +555,7 @@ func (s *Span) toEvent() *Event {
555555
finished := make([]*Span, 0, len(children))
556556
for _, child := range children {
557557
if child.EndTime.IsZero() {
558-
Logger.Printf("Dropped unfinished span: Op=%q TraceID=%s SpanID=%s", child.Op, child.TraceID, child.SpanID)
558+
DebugLogger.Printf("Dropped unfinished span: Op=%q TraceID=%s SpanID=%s", child.Op, child.TraceID, child.SpanID)
559559
continue
560560
}
561561
finished = append(finished, child)

0 commit comments

Comments
 (0)