fix log writer crash
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
This commit is contained in:
parent
0824512a46
commit
1f9b3730d4
@ -20,8 +20,13 @@ func (lw *LogWriter) Write(m []byte) (n int, err error) {
|
|||||||
lw.lastLine = messages[len(messages)-1]
|
lw.lastLine = messages[len(messages)-1]
|
||||||
|
|
||||||
for _, msg := range messages {
|
for _, msg := range messages {
|
||||||
|
messageBody := msg
|
||||||
|
|
||||||
// Remove timestamp
|
// Remove timestamp
|
||||||
messageBody := strings.TrimSpace(strings.SplitN(msg, " ", 3)[2])
|
splittedMsg := strings.SplitN(msg, " ", 3)
|
||||||
|
if len(splittedMsg) > 2 {
|
||||||
|
messageBody = strings.TrimSpace(strings.SplitN(msg, " ", 3)[2])
|
||||||
|
}
|
||||||
|
|
||||||
// Find level in []
|
// Find level in []
|
||||||
startIndex := strings.Index(messageBody, "[")
|
startIndex := strings.Index(messageBody, "[")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user