From b63f30573766db1e192820bee87d41d4c5beac18 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Tue, 9 Jan 2024 23:22:44 +0100 Subject: [PATCH] fix log writer crash --- xray/log_writer.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xray/log_writer.go b/xray/log_writer.go index c2f66e8f..5fc6b3d1 100644 --- a/xray/log_writer.go +++ b/xray/log_writer.go @@ -20,8 +20,13 @@ func (lw *LogWriter) Write(m []byte) (n int, err error) { lw.lastLine = messages[len(messages)-1] for _, msg := range messages { + messageBody := msg + // 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 [] startIndex := strings.Index(messageBody, "[")