diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-07-03 09:58:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-03 09:58:28 -0700 |
commit | 83a3ac089cff0d05559e6ba5c2c60b09f5cae176 (patch) | |
tree | 51cc53c0a77cf455cf9d700a453b6d57f1604fdb /mlog/stdlog.go | |
parent | 3848cb7e79e019e2f0878d6e2377ad36b3c7ca43 (diff) | |
download | chat-83a3ac089cff0d05559e6ba5c2c60b09f5cae176.tar.gz chat-83a3ac089cff0d05559e6ba5c2c60b09f5cae176.tar.bz2 chat-83a3ac089cff0d05559e6ba5c2c60b09f5cae176.zip |
MM-11029 Adding plugin logging functionality. (#9034)
* Capturing stdout, stderr of plugins in logs.
* Cleanup go-plugin debug logs.
* Adding logging to plugin API
* Generating mocks.
* godoc convention
Diffstat (limited to 'mlog/stdlog.go')
-rw-r--r-- | mlog/stdlog.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mlog/stdlog.go b/mlog/stdlog.go index a875b2e32..7839ddfa0 100644 --- a/mlog/stdlog.go +++ b/mlog/stdlog.go @@ -4,6 +4,7 @@ package mlog import ( + "bytes" "strings" "go.uber.org/zap" @@ -72,3 +73,15 @@ func getStdLogOption() zap.Option { }, ) } + +type loggerWriter struct { + logFunc func(msg string, fields ...Field) +} + +func (l *loggerWriter) Write(p []byte) (int, error) { + trimmed := string(bytes.TrimSpace(p)) + for _, line := range strings.Split(trimmed, "\n") { + l.logFunc(string(line)) + } + return len(p), nil +} |