Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion generic_config_updater/generic_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ def apply(self, patch):
self.logger.log_notice(f" * {change}")

# Apply changes in order
self.logger.log_notice("Applying changes in order.")
if changes_len:
self.logger.log_notice(f"Applying {changes_len} change{'s' if changes_len != 1 else ''} in order:")
else:
self.logger.log_notice(f"No changes to apply.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it simple, how about

            self.logger.log_notice(f"Applying {changes_len} change(s) in order:")

And no need to use if-else.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer log messages to be very informative even if they need a little extra code.

In case of 0, I prefer printing a clear message saying

No changes to apply.

In case of 1 change:

Applying 1 change in order:

In case of many changes:

Applying x changes in order:

I think this makes the logs easier to read.

Copy link
Copy Markdown
Contributor Author

@ghooo ghooo Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make it

self.logger.log_notice(f"Applying {changes_len} change{'s' if changes_len != 1 else ''} in order{':' if changes_len > 0 else '.'}")

less informative but not by much, but still easy to understand, and consistent with the previous list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

for change in changes:
self.logger.log_notice(f" * {change}")
self.changeapplier.apply(change)

# Validate config updated successfully
Expand Down