I wrote a simple bash function that will make the output of the freeswitch log files colored like fs_cli does.
Paste it into /etc/bash.bashrc (or in ~./.bashrc) and run
Bash:
function fs_log() {
if [ $# -eq 0 ]
then
echo "Error: Missing required argument 'file'"
return 1
fi
if [ ! -f $1 ]
then
echo "Error: No such file '$1'"
return 1
fi
trap 'echo -ne "\e[0m"' SIGINT
cat $1 | while read line
do
if [[ "$line" == *"[DEBUG]"* ]]
then
echo -e "\e[1;33m${line}\e[0m"
elif [[ "$line" == *"[INFO]"* ]]
then
echo -e "\e[1;32m${line}\e[0m"
elif [[ "$line" == *"[NOTICE]"* ]]
then
echo -e "\e[1;36m${line}\e[0m"
elif [[ "$line" == *"[WARNING]"* ]]
then
echo -e "\e[1;35m${line}\e[0m"
elif [[ "$line" == *"[ERR]"* ]]
then
echo -e "\e[1;31m${line}\e[0m"
elif [[ "$line" == *"[CRIT]"* ]]
then
echo -e "\e[1;31m${line}\e[0m"
elif [[ "$line" == *"[ALERT]"* ]]
then
echo -e "\e[1;31m${line}\e[0m"
else
echo -e "\e[1;33m${line}\e[0m"
fi
done
}
Paste it into /etc/bash.bashrc (or in ~./.bashrc) and run
source /etc/bash.bashrc
, and you get a new command fs_log
that takes the log file as an argument
Last edited: