Skip to content

[ feature request ] Logs in table format #40

@yonas

Description

@yonas

It would be nice to be able to view the logs in a table using the CLI instead of creating one using the JSON.

Example

RUN ID                                 WORKFLOW   STATUS      STARTED AT            DURATION                                                                                                                  
2a693ed0-48b8-41ea-8403-c77de021dbc9   example    ✘ failure   2026-02-05 09:33:12   0.004s

where the STATUS column would be green on success and red on failure. Here's a fish script that does this:

#!/usr/bin/env fish

# Execute pipelight and pipe directly into processing
pipelight logs --json | gojq -n -r '
  # 1. Capture and flatten input stream
  [inputs] | flatten | .[] |

  # 2. Map basic fields
  .uuid as $id |
  (.name | if . == "extract" then "example" else . end) as $workflow |
  .status as $raw_status |
  (.duration.started_at // "N/A")[0:19] as $start |

  # 3. Precision Duration Calculation
  (if .duration.ended_at and .duration.started_at then
      ((.duration.ended_at | sub(" "; "T") | split(".")[0] + "Z" | fromdateiso8601)) as $end_s |
      ((.duration.started_at | sub(" "; "T") | split(".")[0] + "Z" | fromdateiso8601)) as $start_s |
      ((.duration.ended_at | split(".")[1] | .[0:3] | tonumber) / 1000) as $end_ms |
      ((.duration.started_at | split(".")[1] | .[0:3] | tonumber) / 1000) as $start_ms |
      ((($end_s + $end_ms) - ($start_s + $start_ms)) * 1000 | round / 1000 | tostring + "s")
  else
      "running"
  end) as $dur |

  # 4. Output TSV
  [ $id, $workflow, $raw_status, $start, $dur ] | @tsv
' | begin
    # 5. Header with Underline (Using exact character widths)
    set_color -u
    printf "%-38s %-10s %-11s %-21s %s
" "RUN ID" "WORKFLOW" "STATUS" "STARTED AT" "DURATION"
    set_color normal

    # 6. Read and format output
    while read -l -d 	 id workflow raw_status start duration
        set -l status_icon ""
        set -l status_color ""

        # Assign values based on status
        if test "$raw_status" = "succeeded"
            set status_icon "✓ success"
            set status_color green
        else if test "$raw_status" = "failed"
            set status_icon "✘ failure"
            set status_color red
        else
            set status_icon "? $raw_status"
            set status_color yellow
        end

        # 7. The Alignment Fix
        # We print the ID and Workflow, then use set_color,
        # then print the Status icon manually to avoid printf offset bugs.
        printf "%-38s %-10s " $id $workflow
        set_color $status_color
        printf "%-11s " "$status_icon"
        set_color normal
        printf "%-21s %s
" "$start" $duration
    end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions