From 56ccaefabd489a06199b8f0671fd447aedc1ad31 Mon Sep 17 00:00:00 2001 From: iwannay <772648576@qq.com> Date: Sat, 24 Aug 2019 11:23:24 +0800 Subject: [PATCH] fix #53 --- CHANGELOG.md | 1 + go.mod | 2 -- go.sum | 4 ---- jiacrontabd/cmd.go | 9 ++++----- pkg/finder/finder.go | 11 ++++++++--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89b22026..41ebf9a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## v2.0.4 1.修复常驻任务无法删除 +2.修复查看日志在特殊情况下日志异常 ## v2.0.3 1.修复特定情况下节点失去连接 diff --git a/go.mod b/go.mod index ccc32889..9d519774 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( github.com/go-check/check v1.0.0-20180628173108-788fd7840127 // indirect github.com/gofrs/uuid v3.2.0+incompatible github.com/golang/protobuf v1.3.2 // indirect - github.com/google/go-querystring v1.0.0 // indirect github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c // indirect github.com/gorilla/schema v1.1.0 // indirect github.com/imkira/go-interpol v1.1.0 // indirect @@ -57,7 +56,6 @@ require ( github.com/xeipuuv/gojsonschema v1.1.0 // indirect github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect github.com/yudai/gojsondiff v1.0.0 // indirect - github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect github.com/yudai/pp v2.0.1+incompatible // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df diff --git a/go.sum b/go.sum index 18e09173..d6b1c85e 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,6 @@ github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8l github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -217,8 +215,6 @@ github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJx github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= diff --git a/jiacrontabd/cmd.go b/jiacrontabd/cmd.go index 8eeeaae7..0b9337c7 100644 --- a/jiacrontabd/cmd.go +++ b/jiacrontabd/cmd.go @@ -149,14 +149,13 @@ func (cu *cmdUint) exec() error { cu.writeLog(cu.content) go func() { var ( - err error line []byte ) for { - line, err = reader.ReadBytes('\n') - if err != nil || err == io.EOF { + line, _ = reader.ReadBytes('\n') + if len(line) == 0 { break } @@ -172,8 +171,8 @@ func (cu *cmdUint) exec() error { } for { - line, err = readerErr.ReadBytes('\n') - if err != nil || err == io.EOF { + line, _ = readerErr.ReadBytes('\n') + if len(line) == 0 { break } // 默认给err信息加上日期标志 diff --git a/pkg/finder/finder.go b/pkg/finder/finder.go index e3b9d935..bae39ffb 100644 --- a/pkg/finder/finder.go +++ b/pkg/finder/finder.go @@ -100,8 +100,9 @@ func (fd *Finder) find(fpath string, modifyTime time.Time) error { for { - bts, err := reader.ReadBytes('\n') - if err != nil { + bts, _ := reader.ReadBytes('\n') + + if len(bts) == 0 { break } @@ -112,6 +113,9 @@ func (fd *Finder) find(fpath string, modifyTime time.Time) error { } if fd.isTail { + if fd.offset == 0 { + bts = append(bts, '\n') + } invert(bts) } @@ -124,11 +128,12 @@ func (fd *Finder) find(fpath string, modifyTime time.Time) error { break } - if fd.offset == 0 { + if fd.offset <= 0 { break } } + if len(matchData) > 0 { fd.matchDataQueue = append(fd.matchDataQueue, matchDataChunk{ modifyTime: modifyTime,