Last active
October 16, 2018 16:19
-
-
Save gokusenz/f2a2c14f57f2ee7e509d14c5119880d3 to your computer and use it in GitHub Desktop.
It's the only was we can get Stackdriver to display logs correctly when running as a Kubernetes app in Google's cloud.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type OutputSplitter struct{} | |
| func (splitter *OutputSplitter) Write(p []byte) (n int, err error) { | |
| if bytes.Contains(p, []byte("error")) { | |
| return os.Stderr.Write(p) | |
| } | |
| return os.Stdout.Write(p) | |
| } | |
| logrus.SetOutput(&OutputSplitter{}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment