JSONise a cwltool debug error log

Given the following workflow (with no inputs)

#!/usr/bin/env cwl-runner
class: Workflow
cwlVersion: v1.0

inputs: {}

outputs:
  - id: output_wf
    outputSource: my_first_step/output_log
    type: string

steps:
  my_first_step:
    run:
      class: CommandLineTool
      requirements:
        - class: DockerRequirement
          dockerPull: "alpine:latest"
        - class: InlineJavascriptRequirement
        - class: InitialWorkDirRequirement
          listing:
            - entryname: run.sh
              entry: |
                #!/usr/bin/env sh

                echo -n "My basic tool"

      inputs: {}
      stdout: stdout.txt
      outputs:
        - id: output_log
          type: string
          outputBinding:
            glob: stdout.txt
            loadContents: true
            outputEval: $(self[0].contents)
      baseCommand: sh
      arguments:
        - run.sh
    in: {}
    out:
      - id: output_log

I can run cwltool --debug and get the following stderr

INFO /home/alexiswl/miniforge3/envs/cwl-ica/bin/cwltool 3.1.20230624081518
INFO Resolved 'foo.cwl' to 'file:///tmp/tmp.HLhGFfydkY/foo.cwl'
DEBUG Parsed job order from command line: {
    "id": "foo.cwl"
}
DEBUG [workflow ] initialized from file:///tmp/tmp.HLhGFfydkY/foo.cwl
INFO [workflow ] start
DEBUG [workflow ] inputs {}
INFO [workflow ] starting step my_first_step
DEBUG [step my_first_step] job input {}
DEBUG [step my_first_step] evaluated job input to {}
INFO [step my_first_step] start
DEBUG [job my_first_step] initializing from file:///tmp/tmp.HLhGFfydkY/foo.cwl#my_first_step/9dc27904-2183-4ff2-9a5d-1c6324e4fd4c as part of step my_first_step
DEBUG [job my_first_step] {}
DEBUG [job my_first_step] path mappings is {}
DEBUG [job my_first_step] command line bindings is [
        {
            "position": [
                -1000000,
                0
            ],
            "datum": "sh"
        },
        {
            "position": [
                0,
                0
            ],
            "datum": "run.sh"
        }
    ]
DEBUG [job my_first_step] initial work dir {
    "_:c0aaf467-3b9c-4a3d-b29a-7b908b7d58ee": [
        "#!/usr/bin/env sh\n\necho -n \"My basic tool\" \n",
        "/tdidkb/run.sh",
        "CreateFile",
        true
    ]
}
INFO [job my_first_step] /tmp/befv48p7$ docker \
    run \
    -i \
    --mount=type=bind,source=/tmp/befv48p7,target=/tdidkb \
    --mount=type=bind,source=/tmp/vo8g7cmc,target=/tmp \
    --workdir=/tdidkb \
    --read-only=true \
    --log-driver=none \
    --user=1000:1000 \
    --rm \
    --cidfile=/tmp/lt90ptqs/20230703210305-792241.cid \
    --env=TMPDIR=/tmp \
    --env=HOME=/tdidkb \
    alpine:latest \
    sh \
    run.sh > /tmp/befv48p7/stdout.txt
INFO [job my_first_step] Max memory used: 0MiB
INFO [job my_first_step] completed success
DEBUG [job my_first_step] outputs {
    "output_log": "My basic tool"
}
DEBUG [step my_first_step] produced output {
    "file:///tmp/tmp.HLhGFfydkY/foo.cwl#my_first_step/output_log": "My basic tool"
}
INFO [step my_first_step] completed success
INFO [workflow ] completed success
DEBUG [workflow ] outputs {
    "output_wf": "My basic tool"
}
DEBUG [job my_first_step] Removing input staging directory /tmp/xncm59_2
DEBUG [job my_first_step] Removing temporary directory /tmp/vo8g7cmc
DEBUG Removing intermediate output directory /tmp/0npdrra0
DEBUG Removing intermediate output directory /tmp/befv48p7
INFO Final process status is success

Wondering if anyone has already worked on something to convert this into digestible format.

Might look something like

{
  "steps": [
    {
      "id": "my_first_step",
      "initialworkdirfiles": [
        {
          "_:c0aaf467-3b9c-4a3d-b29a-7b908b7d58ee": [
            "#!/usr/bin/env sh\n\necho -n \"My basic tool\" \n",
            "/tdidkb/run.sh",
            "CreateFile",
            true
          ]
        }
      ],
      "commandLineBindings": [
        {
          "position": [
            -1000000,
            0
          ],
          "datum": "sh"
        },
        {
          "position": [
            0,
            0
          ],
          "datum": "run.sh"
        }
      ],
      "dockerCommand": [
        "docker",
        "run",
        "-i",
        "--mount=type=bind,source=/tmp/befv48p7,target=/tdidkb",
        "--mount=type=bind,source=/tmp/vo8g7cmc,target=/tmp",
        "--workdir=/tdidkb",
        "--read-only=true",
        "--log-driver=none",
        "--user=1000:1000",
        "--rm",
        "--cidfile=/tmp/lt90ptqs/20230703210305-792241.cid",
        "--env=TMPDIR=/tmp",
        "--env=HOME=/tdidkb",
        "alpine:latest",
        "sh",
        "run.sh"
      ]
    }
  ]
}

Nice idea @alexiswl ; yeah, I would happily review and likely accept a code contribution to add this as an optional logging output format for cwltool