Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix logging #998

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions _examples/cluster-reentrancy/hello_grain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,24 @@ package main

import (
errors "errors"
slog "log/slog"
"os"

"github.com/asynkron/protoactor-go/cluster"
)

type HelloGrain struct {
logger *slog.Logger
}

func NewHelloGrain() Hello {
return &HelloGrain{
logger: slog.New(slog.NewJSONHandler(os.Stdout, nil)),
}
return &HelloGrain{}
}

// Init implements Hello.
func (g *HelloGrain) Init(ctx cluster.GrainContext) {
g.logger.Info("HelloGrain Init")
ctx.Logger().Info("HelloGrain Init")
}

// ReceiveDefault implements Hello.
func (g *HelloGrain) ReceiveDefault(ctx cluster.GrainContext) {
g.logger.Info("HelloGrain ReceiveDefault")
ctx.Logger().Info("HelloGrain ReceiveDefault")
}

// InvokeService implements Hello.
Expand Down Expand Up @@ -81,5 +75,5 @@ func (g *HelloGrain) DoWork(req *DoWorkRequest, ctx cluster.GrainContext) (*DoWo

// Terminate implements Hello.
func (g *HelloGrain) Terminate(ctx cluster.GrainContext) {
g.logger.Info("HelloGrain Terminate")
ctx.Logger().Info("HelloGrain Terminate")
}