diff --git a/clog/clog_test.go b/clog/clog_test.go index d0b1245..b47c61a 100644 --- a/clog/clog_test.go +++ b/clog/clog_test.go @@ -27,46 +27,40 @@ package clog import ( "context" - "io" - "log/syslog" "os" - "runtime" - "strings" "testing" - "time" "github.com/inconshreveable/log15" - "github.com/papertrail/go-tail/follower" . "github.com/smartystreets/goconvey/convey" fl "github.com/wtsi-ssg/wr/fs/file" ft "github.com/wtsi-ssg/wr/fs/test" ) -// checkLogFollower verifies the log generated by a custom log handler and -// returns false if timeout occurs. -func checkLogFollower(tailLogFollower *follower.Follower) bool { - logChan := make(chan string, 1) +// // checkLogFollower verifies the log generated by a custom log handler and +// // returns false if timeout occurs. +// func checkLogFollower(tailLogFollower *follower.Follower) bool { +// logChan := make(chan string, 1) - go func() { - for line := range tailLogFollower.Lines() { - if strings.Contains(line.String(), "wrrunner") { - logChan <- line.String() +// go func() { +// for line := range tailLogFollower.Lines() { +// if strings.Contains(line.String(), "wrrunner") { +// logChan <- line.String() - break - } - } - }() +// break +// } +// } +// }() - select { - case tailedLog := <-logChan: - So(tailedLog, ShouldContainSubstring, "lvl=warn") - So(tailedLog, ShouldContainSubstring, "foo=1") +// select { +// case tailedLog := <-logChan: +// So(tailedLog, ShouldContainSubstring, "lvl=warn") +// So(tailedLog, ShouldContainSubstring, "foo=1") - return true - case <-time.After(3 * time.Second): - return false - } -} +// return true +// case <-time.After(3 * time.Second): +// return false +// } +// } func TestLogger(t *testing.T) { background := context.Background() @@ -241,38 +235,38 @@ func TestLogger(t *testing.T) { err := ToFileAtLevel("!/*&^%$", "debug") So(err, ShouldNotBeNil) }) - - Convey("Given a custom handler", t, func() { - ctx := context.Background() - handler, err := log15.SyslogHandler(syslog.LOG_USER, - "wrrunner", log15.LogfmtFormat()) - So(err, ShouldBeNil) - - Convey("it can log at given level", func() { - syslogpath := "/var/log/syslog" - - if runtime.GOOS == "darwin" { - syslogpath = "/var/log/system.log" - } else if runtime.GOOS == "windows" { - t.Skip("skipping test; windows os not supported.") - } - - tailLogFollower, err := follower.New(syslogpath, follower.Config{ - Whence: io.SeekEnd, - Offset: 0, - Reopen: true, - }) - So(err, ShouldBeNil) - - ToHandlerAtLevel(handler, "warn") - Warn(ctx, "msg", "foo", 1) - - if !checkLogFollower(tailLogFollower) { - t.Error("Timeout waiting for a log from custom handler") - t.Fail() - } - - tailLogFollower.Close() - }) - }) } + +// Convey("Given a custom handler", t, func() { +// ctx := context.Background() +// handler, err := log15.SyslogHandler(syslog.LOG_USER, +// "wrrunner", log15.LogfmtFormat()) +// So(err, ShouldBeNil) + +// Convey("it can log at given level", func() { +// syslogpath := "/var/log/syslog" + +// if runtime.GOOS == "darwin" { +// syslogpath = "/var/log/system.log" +// } else if runtime.GOOS == "windows" { +// t.Skip("skipping test; windows os not supported.") +// } + +// tailLogFollower, err := follower.New(syslogpath, follower.Config{ +// Whence: io.SeekEnd, +// Offset: 0, +// Reopen: true, +// }) +// So(err, ShouldBeNil) + +// ToHandlerAtLevel(handler, "warn") +// Warn(ctx, "msg", "foo", 1) + +// if !checkLogFollower(tailLogFollower) { +// t.Error("Timeout waiting for a log from custom handler") +// t.Fail() +// } + +// tailLogFollower.Close() +// }) +// }) diff --git a/go.mod b/go.mod index f9e8dc1..144f6d6 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/mattn/go-colorable v0.1.8 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.1 - github.com/papertrail/go-tail v0.0.0-20180509224916-973c153b0431 github.com/ricochet2200/go-disk-usage v0.0.0-20150921141558-f0d1b743428f github.com/rs/xid v1.3.0 github.com/sb10/l15h v0.0.0-20170510122137-64c488bf8e22 diff --git a/go.sum b/go.sum index 4f00436..3016d1f 100644 --- a/go.sum +++ b/go.sum @@ -243,7 +243,6 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA= github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= @@ -470,8 +469,6 @@ github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d/go.m github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs= github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqiriPsEqVhc+svHE= github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3ogry1nUQF8Evvo= -github.com/papertrail/go-tail v0.0.0-20180509224916-973c153b0431 h1:i1egM7gz4bPxLCIwBJOkpk6TqHpjTnL4dE1xdN/4dcs= -github.com/papertrail/go-tail v0.0.0-20180509224916-973c153b0431/go.mod h1:dMID0RaS2a5rhpOjC4RsAKitU6WGgkFBZnPVffL69b8= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=