Skip to content

Commit

Permalink
feat: add logger to PID for accessibility within actors
Browse files Browse the repository at this point in the history
  • Loading branch information
Tochemey committed Sep 6, 2024
1 parent d168d34 commit 524330a
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions actors/pid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2584,23 +2584,12 @@ func TestNewPID(t *testing.T) {
})
}
func TestLogger(t *testing.T) {
ctx := context.TODO()
buffer := new(bytes.Buffer)
buffer.Reset()

actorPath := NewPath("Test", NewAddress("sys", "host", 1))
pid, err := newPID(
ctx,
actorPath,
&exchanger{},
withInitMaxRetries(1),
withCustomLogger(log.New(log.InfoLevel, buffer)),
withAskTimeout(replyTimeout))

require.NoError(t, err)
require.NotNil(t, pid)

buffer.Reset()
pid := &PID{
logger: log.New(log.InfoLevel, buffer),
fieldsLocker: &sync.RWMutex{},
}

pid.Logger().Info("test debug")
actual, err := extractMessage(buffer.Bytes())
Expand All @@ -2612,6 +2601,5 @@ func TestLogger(t *testing.T) {
t.Cleanup(func() {
// reset the buffer
buffer.Reset()
assert.NoError(t, pid.Shutdown(ctx))
})
}

0 comments on commit 524330a

Please sign in to comment.