diff options
Diffstat (limited to 'plugins/server')
-rw-r--r-- | plugins/server/plugin.go | 18 |
1 files changed, 12 insertions, 6 deletions
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)) +} |