Skip to content

Commit

Permalink
fix log writer crash
Browse files Browse the repository at this point in the history
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
  • Loading branch information
MHSanaei and alireza0 committed Jan 10, 2024
1 parent 0824512 commit 1f9b373
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xray/log_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "[")
Expand Down

0 comments on commit 1f9b373

Please sign in to comment.