summaryrefslogtreecommitdiff
path: root/plugins/server/plugin.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-04-04 19:31:06 +0300
committerValery Piashchynski <[email protected]>2021-04-04 19:31:06 +0300
commitc6b123af6464c3c6fd79bf1fc28da71c300eb7b3 (patch)
treeed9c1f087e68a2c70ac002466c233469563fc5e9 /plugins/server/plugin.go
parent10a153e9df62bcbdf77c5b5a63daf5ea7b792495 (diff)
- Update CHANGELOG
- Check log event by logger (mocked) - Modify Stderr event to be as INFO Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/server/plugin.go')
-rw-r--r--plugins/server/plugin.go18
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))
+}