github.com/status-im/status-go@v1.1.0/exportlogs/logs.go (about) 1 package exportlogs 2 3 import ( 4 "fmt" 5 "io/ioutil" 6 ) 7 8 // Log contains actual log content and filename. If content is gzipped Compressed will be set to true. 9 type Log struct { 10 Filename string 11 Content string 12 Compressed bool 13 } 14 15 // ExportResponse contains all available logs 16 type ExportResponse struct { 17 Error string 18 Logs []Log 19 } 20 21 // ExportFromBaseFile reads log file and returns its content with some meta. 22 // In future can be extended to dump rotated logs. 23 func ExportFromBaseFile(logFile string) ExportResponse { 24 data, err := ioutil.ReadFile(logFile) 25 if err != nil { 26 return ExportResponse{Error: fmt.Errorf("error reading file %s: %v", logFile, err).Error()} 27 } 28 return ExportResponse{Logs: []Log{ 29 {Filename: logFile, Compressed: false, Content: string(data)}, 30 }} 31 32 }