Skip to content

Commit e881ebd

Browse files
committed
More logging functions
1 parent 5fa0b0d commit e881ebd

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

mkvrg

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ LC_NUMERIC=C
122122
# for more convenient regex construction
123123
FLOAT_ERE='[+-]?[0-9]+\.[0-9]+'
124124

125+
log_info () {
126+
printf "INFO: %s\n" "$@" >&2
127+
}
128+
129+
log_warn() {
130+
printf "\e[93mWARNING: %s\e[0m\n" "$@" >&2
131+
}
132+
125133
log_error() {
126134
printf "\e[31mERROR: %s\e[0m\n" "$@" >&2
127135
}
@@ -240,7 +248,7 @@ if [[ $PREVIEW == false && $REMUX == true ]]; then
240248
unset muxInFile muxOutFile
241249
continue
242250
fi
243-
echo "INFO: Remuxing '$muxInFile' to '$muxOutFile' $(filePos)."
251+
log_info "Remuxing '$muxInFile' to '$muxOutFile' $(filePos)."
244252
if "$FFMPEG" -y -loglevel error -stats -nostdin -hide_banner -i "$muxInFile" -c copy "$muxOutFile"; then
245253
rm -f "$muxInFile"
246254
else
@@ -271,7 +279,7 @@ for file in "${files[@]}"; do
271279

272280
tracksProcessed=0
273281
for track in $tracks; do
274-
echo "INFO: Running ffmpeg using filter ${FFMPEGFILTER}, this can take a while. (track $track on file '$file') $(filePos) (REFLOUDNESS = $REFLOUDNESS LUFS)"
282+
log_info "Running ffmpeg using filter ${FFMPEGFILTER}, this can take a while. (track $track on file '$file') $(filePos) (REFLOUDNESS = $REFLOUDNESS LUFS)"
275283
ffmpegCmd="$FFMPEG -loglevel info -nostats -nostdin -hide_banner -i \"$file\" -map 0:$track -filter:a \""
276284
if [[ $FFMPEGFILTER == "ebur128" ]]; then
277285
ffmpegCmd="${ffmpegCmd}ebur128=peak=$PEAKTYPE:framelog=quiet\" -f null -"
@@ -302,9 +310,9 @@ for file in "${files[@]}"; do
302310
echo -e "\e[92mNOTICE: Problem finding $FFMPEGFILTER info from ffmpeg for track $track on file '$file' $(filePos).\e[0m"
303311
continue
304312
fi
305-
echo "INFO: Found: Gain ($trackGain dB | $(dBToLufs "$trackGain") LUFS), peak ($trackPeak amplitude | $(amplitudeToDB "$trackPeak") dB) for track $track on file '$file' $(filePos)."
313+
log_info "Found: Gain ($trackGain dB | $(dBToLufs "$trackGain") LUFS), peak ($trackPeak amplitude | $(amplitudeToDB "$trackPeak") dB) for track $track on file '$file' $(filePos)."
306314
if [[ $PREVIEW == true ]]; then
307-
echo "INFO: PREVIEW mode is on, not applying tags, skipping to next track/file."
315+
log_info "PREVIEW mode is on, not applying tags, skipping to next track/file."
308316
continue
309317
fi
310318

@@ -345,10 +353,10 @@ for file in "${files[@]}"; do
345353
sed -i "/^[[:space:]]*$/d" "$tmpFile"
346354
mkvpropedit --tags track:"$((track+1))":"$tmpFile" "$file"
347355
if [[ $VERIFY == true ]] && [[ ! $("$FFMPEG" -nostdin -hide_banner -i "$file" 2>&1) =~ $VERIFY_CHECK ]]; then
348-
echo -e "\e[93mWARNING: Replaygain has not been applied for track $track on file '$file' $(filePos).\e[0m"
356+
log_warn "Replaygain has not been applied for track $track on file '$file' $(filePos)."
349357
continue
350358
fi
351-
echo "INFO: Succesfully applied replaygain tags for track $track on file '$file' $(filePos)."
359+
log_info "Succesfully applied replaygain tags for track $track on file '$file' $(filePos)."
352360
((tracksProcessed++))
353361
done
354362
[[ $tracksProcessed -gt 0 ]] && ((filesProcessed++))

0 commit comments

Comments
 (0)