Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xray
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2024-01-10 15:46:18 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2024-01-10 15:46:18 +0300
commit1f9b3730d4efe1cabb1790ec30aeb13291be4b3b (patch)
treeb0464c5999654bbe425de55088c59419d3085ee3 /xray
parent0824512a462a8d634bf12a94c7f6293866b9c48e (diff)
fix log writer crash
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'xray')
-rw-r--r--xray/log_writer.go7
1 files changed, 6 insertions, 1 deletions
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, "[")