Export logs content with hexary encoding (#1457)

This commit is contained in:
Dmitry Shulyak 2019-05-06 19:08:47 +03:00 committed by GitHub
parent 14c513bd5a
commit 74b29ed4f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -3,14 +3,12 @@ package exportlogs
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"github.com/status-im/go-ethereum/common/hexutil"
) )
// Log contains actual log content and filename. If content is gzipped Compressed will be set to true. // Log contains actual log content and filename. If content is gzipped Compressed will be set to true.
type Log struct { type Log struct {
Filename string Filename string
Content []byte Content string
Compressed bool Compressed bool
} }
@ -28,7 +26,7 @@ func ExportFromBaseFile(logFile string) ExportResponse {
return ExportResponse{Error: fmt.Errorf("error reading file %s: %v", logFile, err).Error()} return ExportResponse{Error: fmt.Errorf("error reading file %s: %v", logFile, err).Error()}
} }
return ExportResponse{Logs: []Log{ return ExportResponse{Logs: []Log{
{Filename: logFile, Compressed: false, Content: hexutil.Bytes(data)}, {Filename: logFile, Compressed: false, Content: string(data)},
}} }}
} }

View File

@ -21,7 +21,7 @@ func TestExportLogs(t *testing.T) {
log := response.Logs[0] log := response.Logs[0]
require.Equal(t, false, log.Compressed) require.Equal(t, false, log.Compressed)
require.Equal(t, tempf.Name(), log.Filename) require.Equal(t, tempf.Name(), log.Filename)
require.Equal(t, logs, string(log.Content)) require.Equal(t, logs, log.Content)
} }
func TestExportLogsNoFileError(t *testing.T) { func TestExportLogsNoFileError(t *testing.T) {