From c6b123af6464c3c6fd79bf1fc28da71c300eb7b3 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Sun, 4 Apr 2021 19:31:06 +0300 Subject: - Update CHANGELOG - Check log event by logger (mocked) - Modify Stderr event to be as INFO Signed-off-by: Valery Piashchynski --- plugins/server/plugin.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'plugins/server/plugin.go') diff --git a/plugins/server/plugin.go b/plugins/server/plugin.go index f708b15e..c3496ae7 100644 --- a/plugins/server/plugin.go +++ b/plugins/server/plugin.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "strings" + "unsafe" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/pkg/transport" @@ -234,10 +235,10 @@ func (server *Plugin) collectEvents(event interface{}) { case events.EventWorkerError: server.log.Error(strings.TrimRight(we.Payload.(error).Error(), " \n\t")) case events.EventWorkerLog: - server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t")) + server.log.Debug(strings.TrimRight(toString(we.Payload.([]byte)), " \n\t")) + // stderr event is INFO level case events.EventWorkerStderr: - // TODO unsafe byte to string convert - server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t")) + server.log.Info(strings.TrimRight(toString(we.Payload.([]byte)), " \n\t")) } } } @@ -248,10 +249,15 @@ func (server *Plugin) collectWorkerLogs(event interface{}) { case events.EventWorkerError: server.log.Error(strings.TrimRight(we.Payload.(error).Error(), " \n\t")) case events.EventWorkerLog: - server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t")) + server.log.Debug(strings.TrimRight(toString(we.Payload.([]byte)), " \n\t")) + // stderr event is INFO level case events.EventWorkerStderr: - // TODO unsafe byte to string convert - server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t")) + server.log.Info(strings.TrimRight(toString(we.Payload.([]byte)), " \n\t")) } } } + +// unsafe, but lightning fast []byte to string conversion +func toString(data []byte) string { + return *(*string)(unsafe.Pointer(&data)) +} -- cgit v1.2.3