Skip to content

Commit d484547

Browse files
committed
Fix: add 'partial_success' logging function
Similar to 'status_success', the 'partial_success' function creates the colored intro to a status line. However, the color and the text depend on the percentage of tasks that succeded, from zero (red) to some (yellow) or all (green)
1 parent ffec56c commit d484547

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

netsim/utils/log.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,17 @@ def status_created() -> None:
408408
def status_success() -> None:
409409
status_green('SUCCESS','OK: ')
410410

411+
"""
412+
Partial success status
413+
"""
414+
def partial_success(s_cnt: int, t_cnt: int) -> None:
415+
if s_cnt == t_cnt:
416+
status_success()
417+
elif s_cnt == 0:
418+
strings.print_colored_text(strings.pad_err_code('ERROR'),'red')
419+
else:
420+
strings.print_colored_text(strings.pad_err_code('PARTIAL'),'yellow')
421+
411422
def section_header(label: str, text: str, color: str = 'green') -> None:
412423
if not strings.rich_color:
413424
print(f'{label} {text}')

0 commit comments

Comments
 (0)