Add logs to the rover status output

This commit is contained in:
Marc Di Luzio 2020-07-09 19:01:09 +01:00
parent b2f169d99f
commit 55c85d2a22
4 changed files with 284 additions and 150 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/mdiluz/rove/pkg/game"
"github.com/mdiluz/rove/pkg/rove"
"github.com/mdiluz/rove/pkg/version"
"google.golang.org/protobuf/types/known/timestamppb"
)
// ServerStatus returns the status of the current server to a gRPC request
@ -90,6 +91,13 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response
Bearing: q.Bearing,
})
}
var logs []*rove.Log
for _, log := range rover.Logs {
logs = append(logs, &rove.Log{
Text: log.Text,
Time: timestamppb.New(log.Time),
})
}
response = &rove.StatusResponse{
Name: rover.Name,
@ -106,6 +114,7 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response
MaximumCharge: int32(rover.MaximumCharge),
IncomingCommands: incoming,
QueuedCommands: queued,
Logs: logs,
}
}
return response, nil