mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-30 05:17:49 +02:00
feat: show systemd service logs in service details (#2440)
Co-authored-by: hank <hank@henrygd.me>
This commit is contained in:
@@ -115,6 +115,16 @@ func unmarshalLegacyResponse(resp common.AgentResponse, action common.WebSocketA
|
||||
}
|
||||
*d = resp.ServiceInfo
|
||||
return nil
|
||||
case common.GetSystemdLogs:
|
||||
d, ok := dest.(*string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected dest type for GetSystemdLogs: %T", dest)
|
||||
}
|
||||
if resp.String == nil {
|
||||
return errors.New("no systemd logs in response")
|
||||
}
|
||||
*d = *resp.String
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unsupported action: %d", action)
|
||||
}
|
||||
|
||||
@@ -31,3 +31,12 @@ func TestUnmarshalSmartDataResponse(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnmarshalSystemdLogsResponse(t *testing.T) {
|
||||
logs := "2026-09-27T12:00:00+00:00 host nginx[1]: started"
|
||||
response := common.AgentResponse{String: &logs}
|
||||
|
||||
var result string
|
||||
require.NoError(t, UnmarshalResponse(response, common.GetSystemdLogs, &result))
|
||||
assert.Equal(t, logs, result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user