Streamlined messages outputted
authorKristian Kræmmer Nielsen <jkkn@jkkn.dk>
Wed, 1 Mar 2017 13:27:17 +0000 (14:27 +0100)
committerKristian Kræmmer Nielsen <jkkn@jkkn.dk>
Wed, 1 Mar 2017 13:27:17 +0000 (14:27 +0100)
monitor-dai.sh

index 553fbad134db67da2e2e0ec295b51ed82fe75e07..9e6b4fdde7cbf2556cd0b4b100b50d6400f76cc7 100755 (executable)
@@ -59,7 +59,7 @@ function resolveRelativeURL() {
         if [[ "$full" =~ $re ]]; then
             echo "${BASH_REMATCH[1]}${relative}"
         else
-            echo >&2 "Unable to split url after hostname: $full"
+            echo >&2 "ERROR: Unable to split url after hostname: $full"
         fi
         return
     fi
@@ -69,7 +69,7 @@ function resolveRelativeURL() {
 }
 
 function fatal() {
-    echo >&2 "Fatal error: $1"
+    echo >&2 "FATAL ERROR: $1"
     exit 1
 }
 
@@ -88,7 +88,7 @@ function resolveFirstStream() {
         fi
       done <"$TMPFILE"
    else
-      echo >&2 "Unable to request: $hls" 
+      echo >&2 "ERROR: Unable to request: $hls" 
    fi
    rm "$TMPFILE"
 }
@@ -110,7 +110,7 @@ function monitorStream() {
     pretty_time=$($DATE${stream_time%.*} +"%Y-%m-%d %H:%M:%S")
 
     echo "NOTICE: Using time-offset of -$STREAM_TIME_SCREW seconds so time is $pretty_time, real time is $(date ${realtime} +"%Y-%m-%d %H:%M:%S")"
-    echo "$pretty_time: Started monitoring using: $stream"
+    echo "$pretty_time: INFO: Started monitoring using: $stream"
 
     while true; do
         starttime=$(date +%s)
@@ -136,7 +136,7 @@ function monitorStream() {
                         stream_time=$(echo "$stream_time + $nextSegmentLength" | bc)
                         pretty_time=$($DATE${stream_time%.*} +"%Y-%m-%d %H:%M:%S")
                         if [[ $curSeq -ne $nextSeq ]]; then
-                            echo >&2 "$pretty_time: WARN: Skipped a segment by mistake ($curSeq > $nextSeq)"
+                            echo >&2 "$pretty_time: WARN: Lost segments ($curSeq > $nextSeq)"
                         fi
                         #echo >&2 "$pretty_time: Current mode length: $curLength"
                         nextSeq=$(($curSeq + 1))
@@ -152,7 +152,7 @@ function monitorStream() {
                 value="${BASH_REMATCH[2]}"
                 if [ "$tag" == "EXT-X-TARGETDURATION" ]; then
                     if [ "$value" != "$target_duration" ]; then
-                        echo "$pretty_time: Changing target duration to: $value"
+                        echo "$pretty_time: INFO: Changing target duration to: $value"
                         target_duration="$value"
                     fi
                 elif [ "$tag" == "EXTINF" ]; then
@@ -167,18 +167,18 @@ function monitorStream() {
                 if [[ $curSeq -ge $nextSeq ]]; then # we are interested in this tag
                     if [ "$tag" == "EXT-X-CUE-OUT" ]; then
                         # Begin ad block
-                        echo "$pretty_time: Seeing CUE-OUT (Ad block start) of duration: $value"
+                        echo "$pretty_time: INFO: Seeing CUE-OUT (Ad block start) of duration: $value"
                         if [ "$mode" == "ADBLOCK" ]; then
                             echo >&2 "$pretty_time: ERROR: Already in ad block - extra cue-out after $curLength"
                         else
-                            echo "$pretty_time: Ad-block started after $curLength seconds"
+                            echo "$pretty_time: INFO: Ad-block started after $curLength seconds"
                         fi
                         mode="ADBLOCK"
                         expectedAdLength=$value
                         curLength=0
                     elif [ "$tag" == "EXT-X-CUE-IN" ]; then
                         # End ad block
-                        echo "$pretty_time: Seeing CUE-IN (Ad block end) after duration: $curLength"
+                        echo "$pretty_time: INFO: Seeing CUE-IN (Ad block end) after duration: $curLength"
                         if [ "$mode" == "ADBLOCK" ]; then
                             if [ "$expectedAdLength" != "$curLength" ]; then
                                 echo >&2 "$pretty_time: WARN: Block was not the length expected ($curLength <> $expectedAdLength)"
@@ -201,7 +201,7 @@ function monitorStream() {
            fi
             
         else
-            echo >&2 "$pretty_time: Unable to request: $stream" 
+            echo >&2 "$pretty_time: WARN: Unable to request: $stream" 
             failed=$(($failed + 1))
         fi
         rm "$TMPFILE"
@@ -222,7 +222,7 @@ function monitorStream() {
 while true; do
     streamurl=$(resolveFirstStream "$1")
     if [ -e "$streamurl" ]; then
-        echo >&2 "Invalid HLS-stream: $1"
+        echo >&2 "ERROR: Invalid HLS-stream: $1"
         sleep 10
     fi