1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Add log error handling

This commit is contained in:
Romein van Buren 2023-07-01 15:03:37 +02:00
parent 7a98a63866
commit 9c85259964
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49

View File

@ -26,11 +26,19 @@ func (a *App) HostLogs(hostKey, filter string) (result HostLogsResult) {
result.Error = err.Error() result.Error = err.Error()
} }
result.Total = res["totalLinesWritten"].(int32) if res["totalLinesWritten"] != nil {
result.Total = res["totalLinesWritten"].(int32)
} else {
result.Total = 0
}
result.Logs = make([]string, 0) result.Logs = make([]string, 0)
for _, v := range res["log"].(bson.A) { switch res["log"].(type) {
result.Logs = append(result.Logs, v.(string)) case bson.A:
for _, v := range res["log"].(bson.A) {
result.Logs = append(result.Logs, v.(string))
}
} }
return return