From 9dbee2a79c3809a0fca1e9d572d6997bbc009f69 Mon Sep 17 00:00:00 2001 From: MAUGIN Thomas Date: Tue, 22 Feb 2022 15:56:27 +0100 Subject: [PATCH] chore(log): prefix logs with colored service name (#71) --- root/etc/services.d/dump1090/run | 4 +++- root/etc/services.d/fr24feed/run | 4 +++- root/etc/services.d/http/run | 4 +++- root/etc/services.d/piaware/run | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/root/etc/services.d/dump1090/run b/root/etc/services.d/dump1090/run index e245ddb..e97e756 100644 --- a/root/etc/services.d/dump1090/run +++ b/root/etc/services.d/dump1090/run @@ -24,7 +24,9 @@ then then /bin/nc ${RTL_TCP_REMOTE_HOST} ${RTL_TCP_REMOTE_PORT} | /usr/lib/fr24/dump1090 --net --write-json /usr/lib/fr24/public_html/data --raw --quiet --lat ${HTML_SITE_LAT} --lon ${HTML_SITE_LON} ${DUMP1090_ADDITIONAL_ARGS} --ifile - else - /usr/lib/fr24/dump1090 --net --write-json /usr/lib/fr24/public_html/data --raw --quiet --lat ${HTML_SITE_LAT} --lon ${HTML_SITE_LON} ${DUMP1090_ADDITIONAL_ARGS} + /usr/lib/fr24/dump1090 --net --write-json /usr/lib/fr24/public_html/data --raw --quiet --lat ${HTML_SITE_LAT} --lon ${HTML_SITE_LON} ${DUMP1090_ADDITIONAL_ARGS} 2>&1 | stdbuf -o0 sed --unbuffered '/^$/d' | mawk -W interactive '{printf "%c[31m [dump1090]%c[0m " $0 "\n", 27, 27}' + # stdbuf ... -- (remove blank lines from output) + # awk -W interactive ... (prefix log messages with color and "[dump1090]") fi else tail -f /dev/null diff --git a/root/etc/services.d/fr24feed/run b/root/etc/services.d/fr24feed/run index 9fd2f4e..4eca6a6 100644 --- a/root/etc/services.d/fr24feed/run +++ b/root/etc/services.d/fr24feed/run @@ -1,7 +1,9 @@ #!/usr/bin/with-contenv bash if [ "$SERVICE_ENABLE_FR24FEED" != "false" ] then - /fr24feed/fr24feed/fr24feed + /fr24feed/fr24feed/fr24feed 2>&1 | stdbuf -o0 sed --unbuffered '/^$/d' | mawk -W interactive '{printf "%c[34m [fr24feed]%c[0m " $0 "\n", 27, 27}' + # stdbuf ... -- (remove blank lines from output) + # awk -W interactive ... (prefix log messages with color and "[fr24feed]") else tail -f /dev/null fi diff --git a/root/etc/services.d/http/run b/root/etc/services.d/http/run index 7ee95f7..6be710b 100644 --- a/root/etc/services.d/http/run +++ b/root/etc/services.d/http/run @@ -2,7 +2,9 @@ if [ "$SERVICE_ENABLE_HTTP" != "false" ] then cd /usr/lib/fr24/public_html - /usr/bin/python3 -m http.server 8080 + /usr/bin/python3 -m http.server 8080 2>&1 | stdbuf -o0 sed --unbuffered '/^$/d' | mawk -W interactive '{printf "%c[32m [http]%c[0m " $0 "\n", 27, 27}' + # stdbuf ... -- (remove blank lines from output) + # awk -W interactive ... (prefix log messages with color and "[http]") else tail -f /dev/null fi \ No newline at end of file diff --git a/root/etc/services.d/piaware/run b/root/etc/services.d/piaware/run index 1e283a9..c0fc6c8 100644 --- a/root/etc/services.d/piaware/run +++ b/root/etc/services.d/piaware/run @@ -1,7 +1,9 @@ #!/usr/bin/with-contenv bash if [ "$SERVICE_ENABLE_PIAWARE" != "false" ] then - /usr/bin/piaware -plainlog + /usr/bin/piaware -plainlog 2>&1 | stdbuf -o0 sed --unbuffered '/^$/d' | mawk -W interactive '{printf "%c[33m [piaware]%c[0m " $0 "\n", 27, 27}' + # stdbuf ... -- (remove blank lines from output) + # awk -W interactive ... (prefix log messages with color and "[piaware]") else tail -f /dev/null fi