Skip to content

Commit c4a2b18

Browse files
committed
error
1 parent e347519 commit c4a2b18

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

pretty_logger.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Script to display a log file with ERROR lines in red
1+
# Script to display a log file with ERROR lines in red.
2+
# It displays the latest 200 lines of the log file.
23
# It assumes that the errors are logged as for example:
34
# 2025-03-25 15:10:15 ERROR 'int' object has no attribute 'split'
45
#
@@ -30,4 +31,11 @@ fi
3031
# Get the log file from command line argument or use default
3132
LOG_FILE="${1:-app.log}"
3233

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+
3341
tail -n 200 -f "$LOG_FILE" | awk '/ERROR/{print "\033[31m" $0 "\033[0m"; next} {print $0}'

0 commit comments

Comments
 (0)