<commit_before>if [ -z "$scriptname" ]; then
	echo "redirectlog error: no scriptname given."
	exit 1
fi

if [ -z "$logfile" ]; then
	echo "redirectlog error: no logfile name given."
	exit 1
fi

# This script redirects stdout to a file and timestamps every line.
logpipe=/tmp/$scriptname.pipe
rm -f $logpipe
# Setting up a trap to delete the pipe on exit
trap "rm -f $logpipe" EXIT
# Creating pipe
mknod $logpipe p
# Reading from the log pipe and processing it.
awk '{ print strftime("[%Y/%m/%d %H:%M:%S]"), $0; }' $logpipe >> $logfile &
# Closing stdout
exec 1>&-
# Redirecting stdout to the pipe
exec 1>$logpipe
exec 2>&1<commit_msg>moved and added a comment to redirectlog.src.sh<commit_after># This script redirects stdout to a file and timestamps every line.
# The script should be sourced, not executed directly.

if [ -z "$scriptname" ]; then
	echo "redirectlog error: no scriptname given."
	exit 1
fi

if [ -z "$logfile" ]; then
	echo "redirectlog error: no logfile name given."
	exit 1
fi

logpipe=/tmp/$scriptname.pipe
rm -f $logpipe
# Setting up a trap to delete the pipe on exit
trap "rm -f $logpipe" EXIT
# Creating pipe
mknod $logpipe p
# Reading from the log pipe and processing it.
awk '{ print strftime("[%Y/%m/%d %H:%M:%S]"), $0; }' $logpipe >> $logfile &
# Closing stdout
exec 1>&-
# Redirecting stdout to the pipe
exec 1>$logpipe
exec 2>&1
{'fraction_non_alphanumeric': 0.12150220913107511, 'fraction_numerical': 0.010309278350515464, 'mean_word_length': 4.109022556390977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7428215', 'n_tokens_mistral': 483, 'n_tokens_neox': 465, 'n_words': 194}