Skip to content

Commit

Permalink
adds timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed Feb 4, 2025
1 parent db928f4 commit 9672c7c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions internal/k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ func (k *K8sClient) FindContainer(ctx context.Context, id string) (container.Con
func (k *K8sClient) ContainerLogs(ctx context.Context, id string, since time.Time, stdType container.StdType) (io.ReadCloser, error) {
podName, containerName := parsePodContainerID(id)
opts := &corev1.PodLogOptions{
Container: containerName,
Follow: true,
Previous: false,
SinceTime: &metav1.Time{Time: since},
Container: containerName,
Follow: true,
Previous: false,
Timestamps: true,
SinceTime: &metav1.Time{Time: since},
}

return k.client.CoreV1().Pods(k.namespace).GetLogs(podName, opts).Stream(ctx)
Expand All @@ -176,9 +177,10 @@ func (k *K8sClient) ContainerLogs(ctx context.Context, id string, since time.Tim
func (k *K8sClient) ContainerLogsBetweenDates(ctx context.Context, id string, start time.Time, end time.Time, stdType container.StdType) (io.ReadCloser, error) {
podName, containerName := parsePodContainerID(id)
opts := &corev1.PodLogOptions{
Container: containerName,
Follow: false,
SinceTime: &metav1.Time{Time: start},
Container: containerName,
Follow: false,
Timestamps: true,
SinceTime: &metav1.Time{Time: start},
}

return k.client.CoreV1().Pods(k.namespace).GetLogs(podName, opts).Stream(ctx)
Expand Down

0 comments on commit 9672c7c

Please sign in to comment.