diff --git a/alt_exit_test.go b/alt_exit_test.go index 54d503cb4..73104792e 100644 --- a/alt_exit_test.go +++ b/alt_exit_test.go @@ -1,7 +1,6 @@ package logrus import ( - "io/ioutil" "log" "os" "os/exec" @@ -76,14 +75,14 @@ func TestHandler(t *testing.T) { testprog := testprogleader testprog = append(testprog, getPackage()...) testprog = append(testprog, testprogtrailer...) - tempDir, err := ioutil.TempDir("", "test_handler") + tempDir, err := os.MkdirTemp("", "test_handler") if err != nil { log.Fatalf("can't create temp dir. %q", err) } defer os.RemoveAll(tempDir) gofile := filepath.Join(tempDir, "gofile.go") - if err := ioutil.WriteFile(gofile, testprog, 0666); err != nil { + if err := os.WriteFile(gofile, testprog, 0666); err != nil { t.Fatalf("can't create go file. %q", err) } @@ -94,7 +93,7 @@ func TestHandler(t *testing.T) { t.Fatalf("completed normally, should have failed") } - data, err := ioutil.ReadFile(outfile) + data, err := os.ReadFile(outfile) if err != nil { t.Fatalf("can't read output file %s. %q", outfile, err) } diff --git a/hooks/test/test.go b/hooks/test/test.go index 046f0bf6c..4b4d1f1a5 100644 --- a/hooks/test/test.go +++ b/hooks/test/test.go @@ -3,7 +3,7 @@ package test import ( - "io/ioutil" + "io" "sync" "github.com/sirupsen/logrus" @@ -42,7 +42,7 @@ func NewLocal(logger *logrus.Logger) *Hook { func NewNullLogger() (*logrus.Logger, *Hook) { logger := logrus.New() - logger.Out = ioutil.Discard + logger.Out = io.Discard return logger, NewLocal(logger) diff --git a/hooks/writer/writer_test.go b/hooks/writer/writer_test.go index 30f6a496f..5165aa942 100644 --- a/hooks/writer/writer_test.go +++ b/hooks/writer/writer_test.go @@ -2,7 +2,7 @@ package writer import ( "bytes" - "io/ioutil" + "io" "testing" log "github.com/sirupsen/logrus" @@ -16,7 +16,7 @@ func TestDifferentLevelsGoToDifferentWriters(t *testing.T) { DisableTimestamp: true, DisableColors: true, }) - log.SetOutput(ioutil.Discard) // Send all logs to nowhere by default + log.SetOutput(io.Discard) // Send all logs to nowhere by default log.AddHook(&Hook{ Writer: &a, diff --git a/logger_bench_test.go b/logger_bench_test.go index 1699af5aa..61b66780d 100644 --- a/logger_bench_test.go +++ b/logger_bench_test.go @@ -1,7 +1,7 @@ package logrus import ( - "io/ioutil" + "io" "os" "testing" ) @@ -65,7 +65,7 @@ func doLoggerBenchmarkWithFormatter(b *testing.B, f Formatter) { b.SetParallelism(100) log := New() log.Formatter = f - log.Out = ioutil.Discard + log.Out = io.Discard b.RunParallel(func(pb *testing.PB) { for pb.Next() { log. diff --git a/logrus_test.go b/logrus_test.go index f6c2c6eda..fb3f15859 100644 --- a/logrus_test.go +++ b/logrus_test.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "runtime" @@ -636,7 +636,7 @@ func TestReplaceHooks(t *testing.T) { old, cur := &TestHook{}, &TestHook{} logger := New() - logger.SetOutput(ioutil.Discard) + logger.SetOutput(io.Discard) logger.AddHook(old) hooks := make(LevelHooks) @@ -781,7 +781,7 @@ func TestReportCallerOnTextFormatter(t *testing.T) { func TestSetReportCallerRace(t *testing.T) { l := New() - l.Out = ioutil.Discard + l.Out = io.Discard l.SetReportCaller(true) var wg sync.WaitGroup