Skip to content

Commit efc9a15

Browse files
committed
日志新增换行操作
1 parent fb24b13 commit efc9a15

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

log/filelog/http.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ import (
1717
_ "embed"
1818
"encoding/json"
1919
"fmt"
20-
"github.com/dustin/go-humanize"
21-
"github.com/gorilla/websocket"
2220
"html/template"
2321
"net/http"
2422
"os"
2523
"path/filepath"
2624
"strings"
2725
"time"
26+
27+
humanize "github.com/dustin/go-humanize"
28+
29+
"github.com/gorilla/websocket"
2830
)
2931

3032
var (
@@ -225,6 +227,8 @@ func (f *fileServer) watch(w http.ResponseWriter, r *http.Request) {
225227
return
226228
}
227229
if len(grep) == 0 || bytes.Contains(msg, grep) {
230+
// 加上换行,防止数据被截断
231+
msg = append(msg, '\n')
228232
err := conn.WriteMessage(websocket.TextMessage, msg)
229233
if err != nil {
230234
return

0 commit comments

Comments
 (0)