logger: Log to the FTrace buffer if tracing is enabled
[renesas/vsp-tests.git] / scripts / logger.sh
1 #!/bin/sh
2
3 now() {
4         awk '/^now/ {time=$3; printf("[%u.%06u]", time / 1000000000, (time % 1000000000) / 1000) ; exit}' /proc/timer_list
5 }
6
7 label=${1:+ [$1]}
8
9 TRACE_MARKER=/sys/kernel/debug/tracing/trace_marker
10 if [ -e $TRACE_MARKER ]; then
11         extra_log_files=$TRACE_MARKER
12 fi
13
14 while read line ; do
15         newline="$(now)$label $line"
16
17         echo "$newline"
18
19         for f in $extra_log_files; do
20                 echo "$newline" >> $f;
21         done;
22 done