@@ -24,12 +24,12 @@ Options:
24
24
configure_options () {
25
25
echo -e " \n\033[96mCurrent log path: $LOGS_PATH \033[0m\n"
26
26
echo -e " \033[96mCurrent container name: $CONTAINER_NAME \033[0m\n"
27
- read -p " $( echo -e " Do you want to change these values? (\033[92mY\033[0m/\033[91mn\033[0m): " ) " change_option
27
+ read -r - p " $( echo -e " Do you want to change these values? (\033[92mY\033[0m/\033[91mn\033[0m): " ) " change_option
28
28
29
29
if [[ " $change_option " =~ [Yy] ]];
30
30
then
31
- read -p " Enter the new log path (press Enter to keep current path): " new_logs_path
32
- read -p " Enter the new container name (press Enter to keep current name): " new_container_name
31
+ read -r - p " Enter the new log path (press Enter to keep current path): " new_logs_path
32
+ read -r - p " Enter the new container name (press Enter to keep current name): " new_container_name
33
33
34
34
if [[ -n " $new_logs_path " ]];
35
35
then
@@ -74,10 +74,14 @@ search_errors () {
74
74
# Loop through each log file
75
75
for log_file in ./log/* .log; do
76
76
# Search for different types of log messages and format the output
77
- local errors=$( grep -E -r --color=always " \(ERROR\|FATAL\|CRITICAL\)" " $log_file " | format_log_output || true)
78
- local warnings=$( grep -E -r --color=always " \bWARNING\b" " $log_file " | format_log_output || true)
79
- local info=$( grep -E -r --color=always " INFO" " $log_file " | format_log_output || true)
80
- local debug=$( grep -E -r --color=always " DEBUG" " $log_file " | format_log_output || true)
77
+ local errors
78
+ errors=$( grep -E -r --color=always " \(ERROR\|FATAL\|CRITICAL\)" " $log_file " | format_log_output || true)
79
+ local warnings
80
+ warnings=$( grep -E -r --color=always " \bWARNING\b" " $log_file " | format_log_output || true)
81
+ local info
82
+ info=$( grep -E -r --color=always " INFO" " $log_file " | format_log_output || true)
83
+ local debug
84
+ debug=$( grep -E -r --color=always " DEBUG" " $log_file " | format_log_output || true)
81
85
# If any errors or warnings are found, print them
82
86
if [ -n " $errors " ] || [ -n " $warnings " ] || [ -n " $info " ] || [ -n " $debug " ]; then
83
87
found_errors=true
@@ -156,15 +160,15 @@ while true;
156
160
echo -e " \033[96m5.\033[0m Configure options"
157
161
158
162
# Read user input for option selection
159
- read -p " Enter the option number (1, 2, 3, 4 or 5): " option
163
+ read -r - p " Enter the option number (1, 2, 3, 4 or 5): " option
160
164
161
165
if [ " $option " == " 1" ];
162
166
then
163
167
show_logs
164
168
elif [ " $option " == " 2" ];
165
169
then
166
170
show_logs
167
- read -p " Enter the log file name (with extension, e.g., system.log): " log_file
171
+ read -r - p " Enter the log file name (with extension, e.g., system.log): " log_file
168
172
view_log " $log_file " | format_log_output
169
173
elif [ " $option " == " 3" ];
170
174
then
@@ -175,10 +179,10 @@ while true;
175
179
echo -e " \033[96m1.\033[0m View all logs in real-time"
176
180
echo -e " \033[96m2.\033[0m View only error logs in real-time"
177
181
178
- read -p " Enter the option number (1 or 2): " tail_option
182
+ read -r - p " Enter the option number (1 or 2): " tail_option
179
183
echo -e " \n\033[96mChoose a log file to tail:\033[0m"
180
184
show_logs
181
- read -p " Enter the log file name (with extension, e.g., system.log): " log_file
185
+ read -r - p " Enter the log file name (with extension, e.g., system.log): " log_file
182
186
echo -e " \033[96mPress [Ctrl+C] to stop tailing logs\033[0m"
183
187
184
188
if [ " $tail_option " == " 1" ];
@@ -192,7 +196,7 @@ while true;
192
196
fi
193
197
194
198
echo -e " \033[96mPress [Enter] to return to the menu\033[0m"
195
- read -r -n 1 -s discard
199
+ read -r -n 1 -s
196
200
docker exec -it " $CONTAINER_NAME " pkill -f " tail -f $LOGS_PATH /$log_file "
197
201
elif [ " $option " == " 5" ];
198
202
then
@@ -203,7 +207,7 @@ while true;
203
207
fi
204
208
205
209
# Ask the user if they want to continue
206
- read -p " $( echo -e " \033[92mContinue (Y/\033[91mn)\033[0m" ) ? " continue_option
210
+ read -r -p " $( echo -e " \033[92mContinue (Y/\033[91mn)\033[0m" ) ? " continue_option
207
211
if [[ " $continue_option " =~ [Nn] ]];
208
212
then
209
213
break
0 commit comments