diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/logger/config.go | 10 | ||||
-rw-r--r-- | plugins/server/plugin.go | 18 |
2 files changed, 22 insertions, 6 deletions
diff --git a/plugins/logger/config.go b/plugins/logger/config.go index 52594bc4..eee5fb71 100644 --- a/plugins/logger/config.go +++ b/plugins/logger/config.go @@ -50,6 +50,16 @@ func (cfg *Config) BuildLogger() (*zap.Logger, error) { zCfg = zap.NewProductionConfig() case "development": zCfg = zap.NewDevelopmentConfig() + case "raw": + zCfg = zap.Config{ + Level: zap.NewAtomicLevelAt(zap.InfoLevel), + Encoding: "console", + EncoderConfig: zapcore.EncoderConfig{ + MessageKey: "message", + }, + OutputPaths: []string{"stderr"}, + ErrorOutputPaths: []string{"stderr"}, + } default: zCfg = zap.Config{ Level: zap.NewAtomicLevelAt(zap.DebugLevel), 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)) +} |