Skip to content

Commit

Permalink
Context Driven Handler slog
Browse files Browse the repository at this point in the history
  • Loading branch information
iamemilio committed Apr 19, 2024
1 parent 8403072 commit 3f71008
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions v3/integrations/logcontext-v2/nrslog/example/main.go
Expand Up @@ -4,6 +4,7 @@ import (
"log/slog"
"os"
"time"
"context"

"github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrslog"
"github.com/newrelic/go-agent/v3/newrelic"
Expand All @@ -24,8 +25,9 @@ func main() {
log.Info("I am a log message")

txn := app.StartTransaction("example transaction")
txnLogger := nrslog.WithTransaction(txn, log)
txnLogger.Info("I am a log inside a transaction")
ctx := newrelic.NewContext(context.Background(), txn)

txnLogger.InfoContext(ctx, "I am a log inside a transaction")

// pretend to do some work
time.Sleep(500 * time.Millisecond)
Expand Down

0 comments on commit 3f71008

Please sign in to comment.