Skip to content

Commit

Permalink
feat: Add better feedback for adding and selecting log files in LogAn…
Browse files Browse the repository at this point in the history
…alyzer mode (#259)
  • Loading branch information
Jesse S authored Jan 18, 2024
1 parent f7c90f4 commit 4d841e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/log_analyzer/log_analyzer_root_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ def __init__(self, asadm_version="", log_path=""):
logs_added = LogAnalyzerRootController.log_handler.get_log_files()

if not logs_added:
logger.warning(
"No log files added. Use the 'add' command to add log files."
)
if log_path != "":
logger.error(
f"Error reading log path {log_path}. Use the 'add' command to add log files."
)
else:
logger.warning(
"No log files added. Use the 'add' command to add log files."
)

LogAnalyzerRootController.command = LogAnalyzerCommandController(
self.log_handler
Expand Down Expand Up @@ -360,7 +365,11 @@ def __init__(self):
self.modifiers = set()

def _do_default(self, line):
self.log_handler.select_logs_by_index(line)
try:
num_selected = self.log_handler.select_logs_by_index(line)
print(f"Successfully selected {num_selected} server log(s).\n")
except LogHandlerException as e:
raise ShellException(e)


@CommandHelp(
Expand Down
5 changes: 5 additions & 0 deletions lib/log_analyzer/log_handler/log_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ def select_logs_by_index(self, indices="all"):

self.selected_logs = selected_list

if not self.selected_logs:
raise LogHandlerException("No log files selected.")

return len(self.selected_logs)

def grep(
self,
logs,
Expand Down

0 comments on commit 4d841e8

Please sign in to comment.