We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e347519 commit c4a2b18Copy full SHA for c4a2b18
1 file changed
pretty_logger.sh
@@ -1,4 +1,5 @@
1
-# Script to display a log file with ERROR lines in red
+# Script to display a log file with ERROR lines in red.
2
+# It displays the latest 200 lines of the log file.
3
# It assumes that the errors are logged as for example:
4
# 2025-03-25 15:10:15 ERROR 'int' object has no attribute 'split'
5
#
@@ -30,4 +31,11 @@ fi
30
31
# Get the log file from command line argument or use default
32
LOG_FILE="${1:-app.log}"
33
34
+# Check if the log file exists
35
+if [ ! -f "$LOG_FILE" ]; then
36
+ echo "ERROR: Log file '$LOG_FILE' does not exist."
37
+ echo "Run '$(basename "$0") --help' for usage information."
38
+ exit 1
39
+fi
40
+
41
tail -n 200 -f "$LOG_FILE" | awk '/ERROR/{print "\033[31m" $0 "\033[0m"; next} {print $0}'
0 commit comments