Created
June 9, 2024 12:05
-
-
Save cbrunnkvist/054f820023c017fe74f1ac8bc8abee09 to your computer and use it in GitHub Desktop.
Colorize any log (ANSI, sed)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Starting screens with logs tailing ..." | |
colors="sed --unbuffered \ | |
-e 's/\\(.*\\[ERROR.*\\)/\\o033[1;31m\\\1\\o033[0;39m/' \ | |
-e 's/\\(.*\\[WARN.*\\)/\\o033[1;33m\\\1\\o033[0;39m/' \ | |
-e 's/\\(.*\\[INFO.*\\)/\\o033[1;32m\\\1\\o033[0;39m/' \ | |
-e 's/\\(.*\\[DEBUG.*\\)/\\o033[1;34m\\\1\\o033[0;39m/' \ | |
-e 's/\\(.*\\[TRACE.*\\)/\\o033[1;35m\\\1\\o033[0;39m/'" | |
screen -d -m -S some-service-console-log | |
screen -S some-service-console-log -p 0 -X stuff "tail -F -n5000 /opt/logs/data.log | ${colors}$(printf \\r)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment