diff --git a/config.go b/config.go index bb079d1..4e793f8 100644 --- a/config.go +++ b/config.go @@ -6,8 +6,6 @@ import ( "path" flag "github.com/spf13/pflag" - - log "github.com/sirupsen/logrus" ) type Config struct { @@ -72,7 +70,6 @@ func (c *Config) ParseArray(arguments []string) { } if c.DefaultHelper { - c.SetupLogging() c.EnableTimeoutHandler() } } @@ -85,13 +82,3 @@ func (c *Config) addDefaultFlags() { c.DefaultFlags = false } - -func (c *Config) SetupLogging() { - if c.Debug { - log.SetLevel(log.DebugLevel) - } else if c.Verbose { - log.SetLevel(log.InfoLevel) - } else { - log.SetLevel(log.WarnLevel) - } -} diff --git a/convert/bytes_common_test.go b/convert/bytes_common_test.go index 579f3e7..8a258ef 100644 --- a/convert/bytes_common_test.go +++ b/convert/bytes_common_test.go @@ -1,43 +1,10 @@ package convert import ( - "fmt" - log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "testing" ) -func ExampleParseBytes() { - bSI, err := ParseBytes("100MB") - if err != nil { - log.Fatal(err) - } - - bIEC, err := ParseBytes("100MiB") - if err != nil { - log.Fatal(err) - } - - fmt.Println("SI units") - fmt.Println(bSI.Bytes()) - fmt.Println(bSI) - fmt.Println(bSI.HumanReadable()) - - fmt.Println("IEC units") - fmt.Println(bIEC.Bytes()) - fmt.Println(bIEC) - fmt.Println(bIEC.HumanReadable()) - // Output: - // SI units - // 100000000 - // 100MB - // 100MB - // IEC units - // 104857600 - // 100MiB - // 100MiB -} - func TestParseBytes(t *testing.T) { b, err := ParseBytes("1024") assert.NoError(t, err) @@ -54,6 +21,12 @@ func TestParseBytes(t *testing.T) { assert.IsType(t, BytesIEC(0), b) assert.Equal(t, uint64(1024*1024), b.Bytes()) + b, err = ParseBytes("100MB") + assert.NoError(t, err) + + b, err = ParseBytes("100MiB") + assert.NoError(t, err) + b, err = ParseBytes(" 23 GiB ") assert.NoError(t, err) assert.IsType(t, BytesIEC(0), b) diff --git a/cmd/check_example/main.go b/examples/check_example/main.go similarity index 92% rename from cmd/check_example/main.go rename to examples/check_example/main.go index 68777a7..ab2b104 100644 --- a/cmd/check_example/main.go +++ b/examples/check_example/main.go @@ -2,7 +2,7 @@ package main import ( "github.com/NETWAYS/go-check" - log "github.com/sirupsen/logrus" + "log" ) func main() { @@ -19,8 +19,9 @@ func main() { config.ParseArguments() - log.Info("Start logging") - + if config.Debug { + log.Println("Start logging") + } // time.Sleep(20 * time.Second) if *value > *critical { diff --git a/cmd/check_example/main_test.go b/examples/check_example/main_test.go similarity index 100% rename from cmd/check_example/main_test.go rename to examples/check_example/main_test.go diff --git a/cmd/check_example2/main.go b/examples/check_example2/main.go similarity index 100% rename from cmd/check_example2/main.go rename to examples/check_example2/main.go diff --git a/cmd/check_example2/main_test.go b/examples/check_example2/main_test.go similarity index 100% rename from cmd/check_example2/main_test.go rename to examples/check_example2/main_test.go diff --git a/go.mod b/go.mod index 1a45f6c..6e6f228 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,7 @@ module github.com/NETWAYS/go-check go 1.14 require ( - github.com/jarcoal/httpmock v1.3.0 github.com/mitchellh/go-ps v1.0.0 - github.com/sirupsen/logrus v1.9.3 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 - gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 91065c5..3389d0c 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +1,19 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/jarcoal/httpmock v1.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nuc= -github.com/jarcoal/httpmock v1.3.0/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= -github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g= -github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM= github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=