ソースを参照

Add support for multi-line log messages

Alois Mahdal 6 年 前
コミット
be48a92bd3
共有1 個のファイルを変更した25 個の追加7 個の削除を含む
  1. 25
    7
      src/jat.sh.skel

+ 25
- 7
src/jat.sh.skel ファイルの表示

@@ -516,33 +516,51 @@ jat__log_error() {
516 516
     #
517 517
     # Log internal error unrelated to SUT
518 518
     #
519
-    local msg=$1
519
+    local line
520
+    local msg
521
+    local head=true
522
+    for line in "$@"; do
523
+        __jat__show_terror "$line"
524
+        $head || msg+=$'\n'; head=false
525
+        msg+="$line"
526
+    done
520 527
     echo "error" >> "$(__jat__sd_path "llog")"
521 528
     echo "error" >> "$(__jat__sd_path "P.llog")"
522 529
     __jat__log_event TEST_ERROR "$msg"
523
-    __jat__show_terror "$msg"
524 530
 }
525 531
 
526 532
 jat__log_info() {
527 533
     #
528 534
     # Log internal info unrelated to SUT
529 535
     #
530
-    local msg=$1
536
+    local line
537
+    local msg
538
+    local head=true
539
+    for line in "$@"; do
540
+        __jat__show_tinfo "$line"
541
+        $head || msg+=$'\n'; head=false
542
+        msg+="$line"
543
+    done
531 544
     echo "info" >> "$(__jat__sd_path "llog")"
532 545
     echo "info" >> "$(__jat__sd_path "P.llog")"
533 546
     __jat__log_event SINFO "$msg"
534
-    __jat__show_tinfo "$msg"
535 547
 }
536 548
 
537 549
 jat__log_warning() {
538 550
     #
539 551
     # Log internal error unrelated to SUT
540 552
     #
541
-    local msg=$1
553
+    local line
554
+    local msg
555
+    local head=true
556
+    for line in "$@"; do
557
+        __jat__show_twarning "$line"
558
+        $head || msg+=$'\n'; head=false
559
+        msg+="$line"
560
+    done
542 561
     echo "warning" >> "$(__jat__sd_path "llog")"
543 562
     echo "warning" >> "$(__jat__sd_path "P.llog")"
544 563
     __jat__log_event TEST_WARNING "$msg"
545
-    __jat__show_twarning "$msg"
546 564
 }
547 565
 
548 566
 jat__pass() {
@@ -1281,7 +1299,7 @@ __jat__yamls() {
1281 1299
     case $value in
1282 1300
         "") echo "    $name: ~" ;;
1283 1301
         *)  echo "    $name: |-"
1284
-            echo "        $value" ;;
1302
+            sed "s/^/        /" <<<"$value" ;;
1285 1303
     esac
1286 1304
 }
1287 1305