From 29ebd30ecc38bc700a89fc5af58b60637ad3ab3a Mon Sep 17 00:00:00 2001 From: Malfurious Date: Thu, 9 Nov 2023 20:17:25 -0500 Subject: dmt: Implement API endpoint /api/log/{jobnum} This returns a plain-text response (not JSON) of the full log file for the requested job number. If `jobnum` is omited, the log of the latest job is returned. Signed-off-by: Malfurious --- dmt/dmt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dmt/dmt b/dmt/dmt index 7923580..ca44b78 100755 --- a/dmt/dmt +++ b/dmt/dmt @@ -65,4 +65,14 @@ api_job() { fi } -api_job +api_log() { + [ -z "$1" ] && job="$(newest_job)" || job="$1" + jobdir="$CYCHE_LOG_DIR/$job" + + if [ -d "$jobdir" ]; then + printf 'Content-type: text/plain\n\n' + cat "$jobdir/log" + fi +} + +api_log -- cgit v1.2.3