1

Asterisk is generating a log file with following content:

#033[1;31mWARNING#033[0m[10505]:#033[1;37mres_phoneprov.c#033[0m:#033[1;37m1232#033[0m #033[1;37mget_defaults#033[0m: #033[1;31mERROR#033[0m[10505]:#033[1;37mconfig_options.c#033[0m:#033[1;37m720#033[0m #033[1;37maco_process_var#033[0m:

How can i read this file with coloured output using included color codes?

  • 1
    Those appear [ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code) which are typically converted to changes in font/background color by your terminal, so you could try `cat logfile` ... – HBruijn Nov 13 '17 at 16:53

2 Answers2

1

Something like this?

tail -f asterisk.log | while read line; do x="$(echo -n ${line}|sed s/'#033'/'\\033'/g)";echo -e $x;done

you can replace 'tail' with 'cat' if you need it.

0

syslog escapes the ansi color codes by default. To enable add the following to the /etc/rsyslog.conf

$EscapeControlCharactersOnReceive off

https://stackoverflow.com/questions/52862237/syslog-how-to-show-colorized-messages