diff options
Diffstat (limited to 'modules/log')
-rw-r--r-- | modules/log/conn_test.go | 4 | ||||
-rw-r--r-- | modules/log/file_test.go | 34 | ||||
-rw-r--r-- | modules/log/stack.go | 4 |
3 files changed, 21 insertions, 21 deletions
diff --git a/modules/log/conn_test.go b/modules/log/conn_test.go index dc5de732f4..158a8ca6ce 100644 --- a/modules/log/conn_test.go +++ b/modules/log/conn_test.go @@ -6,7 +6,7 @@ package log import ( "fmt" - "io/ioutil" + "io" "net" "strings" "sync" @@ -20,7 +20,7 @@ func listenReadAndClose(t *testing.T, l net.Listener, expected string) { conn, err := l.Accept() assert.NoError(t, err) defer conn.Close() - written, err := ioutil.ReadAll(conn) + written, err := io.ReadAll(conn) assert.NoError(t, err) assert.Equal(t, expected, string(written)) diff --git a/modules/log/file_test.go b/modules/log/file_test.go index 7bc5f90037..39d2467a1f 100644 --- a/modules/log/file_test.go +++ b/modules/log/file_test.go @@ -7,7 +7,7 @@ package log import ( "compress/gzip" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "strings" @@ -19,7 +19,7 @@ import ( ) func TestFileLoggerFails(t *testing.T) { - tmpDir, err := ioutil.TempDir("", "TestFileLogger") + tmpDir, err := os.MkdirTemp("", "TestFileLogger") assert.NoError(t, err) defer util.RemoveAll(tmpDir) @@ -47,7 +47,7 @@ func TestFileLoggerFails(t *testing.T) { } func TestFileLogger(t *testing.T) { - tmpDir, err := ioutil.TempDir("", "TestFileLogger") + tmpDir, err := os.MkdirTemp("", "TestFileLogger") assert.NoError(t, err) defer util.RemoveAll(tmpDir) @@ -85,21 +85,21 @@ func TestFileLogger(t *testing.T) { fileLogger.LogEvent(&event) fileLogger.Flush() - logData, err := ioutil.ReadFile(filename) + logData, err := os.ReadFile(filename) assert.NoError(t, err) assert.Equal(t, expected, string(logData)) event.level = DEBUG fileLogger.LogEvent(&event) fileLogger.Flush() - logData, err = ioutil.ReadFile(filename) + logData, err = os.ReadFile(filename) assert.NoError(t, err) assert.Equal(t, expected, string(logData)) event.level = TRACE fileLogger.LogEvent(&event) fileLogger.Flush() - logData, err = ioutil.ReadFile(filename) + logData, err = os.ReadFile(filename) assert.NoError(t, err) assert.Equal(t, expected, string(logData)) @@ -107,18 +107,18 @@ func TestFileLogger(t *testing.T) { expected += fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg) fileLogger.LogEvent(&event) fileLogger.Flush() - logData, err = ioutil.ReadFile(filename) + logData, err = os.ReadFile(filename) assert.NoError(t, err) assert.Equal(t, expected, string(logData)) // Should rotate fileLogger.LogEvent(&event) fileLogger.Flush() - logData, err = ioutil.ReadFile(filename + fmt.Sprintf(".%s.%03d", time.Now().Format("2006-01-02"), 1)) + logData, err = os.ReadFile(filename + fmt.Sprintf(".%s.%03d", time.Now().Format("2006-01-02"), 1)) assert.NoError(t, err) assert.Equal(t, expected, string(logData)) - logData, err = ioutil.ReadFile(filename) + logData, err = os.ReadFile(filename) assert.NoError(t, err) expected = fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg) assert.Equal(t, expected, string(logData)) @@ -134,7 +134,7 @@ func TestFileLogger(t *testing.T) { expected += fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg) fileLogger.LogEvent(&event) fileLogger.Flush() - logData, err = ioutil.ReadFile(filename) + logData, err = os.ReadFile(filename) assert.NoError(t, err) assert.Equal(t, expected, string(logData)) @@ -142,7 +142,7 @@ func TestFileLogger(t *testing.T) { expected += fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg) fileLogger.LogEvent(&event) fileLogger.Flush() - logData, err = ioutil.ReadFile(filename) + logData, err = os.ReadFile(filename) assert.NoError(t, err) assert.Equal(t, expected, string(logData)) @@ -150,7 +150,7 @@ func TestFileLogger(t *testing.T) { } func TestCompressFileLogger(t *testing.T) { - tmpDir, err := ioutil.TempDir("", "TestFileLogger") + tmpDir, err := os.MkdirTemp("", "TestFileLogger") assert.NoError(t, err) defer util.RemoveAll(tmpDir) @@ -184,7 +184,7 @@ func TestCompressFileLogger(t *testing.T) { fileLogger.LogEvent(&event) fileLogger.Flush() - logData, err := ioutil.ReadFile(filename) + logData, err := os.ReadFile(filename) assert.NoError(t, err) assert.Equal(t, expected, string(logData)) @@ -192,7 +192,7 @@ func TestCompressFileLogger(t *testing.T) { expected += fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg) fileLogger.LogEvent(&event) fileLogger.Flush() - logData, err = ioutil.ReadFile(filename) + logData, err = os.ReadFile(filename) assert.NoError(t, err) assert.Equal(t, expected, string(logData)) @@ -210,7 +210,7 @@ func TestCompressFileLogger(t *testing.T) { } func TestCompressOldFile(t *testing.T) { - tmpDir, err := ioutil.TempDir("", "TestFileLogger") + tmpDir, err := os.MkdirTemp("", "TestFileLogger") assert.NoError(t, err) defer util.RemoveAll(tmpDir) fname := filepath.Join(tmpDir, "test") @@ -238,9 +238,9 @@ func TestCompressOldFile(t *testing.T) { assert.NoError(t, err) zr, err := gzip.NewReader(f) assert.NoError(t, err) - data, err := ioutil.ReadAll(zr) + data, err := io.ReadAll(zr) assert.NoError(t, err) - original, err := ioutil.ReadFile(nonGzip) + original, err := os.ReadFile(nonGzip) assert.NoError(t, err) assert.Equal(t, original, data) } diff --git a/modules/log/stack.go b/modules/log/stack.go index 568c10cd00..8fc3f35421 100644 --- a/modules/log/stack.go +++ b/modules/log/stack.go @@ -7,7 +7,7 @@ package log import ( "bytes" "fmt" - "io/ioutil" + "os" "runtime" ) @@ -38,7 +38,7 @@ func Stack(skip int) string { fmt.Fprintf(buf, "%s:%d (0x%x)\n", filename, lineNumber, programCounter) // Now try to print the offending line if filename != lastFilename { - data, err := ioutil.ReadFile(filename) + data, err := os.ReadFile(filename) if err != nil { // can't read this sourcefile // likely we don't have the sourcecode available |