mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-11 20:19:38 +02:00
Modify terminal helper
This commit is contained in:
parent
ac08b17f94
commit
2ca7cd468f
2 changed files with 9 additions and 5 deletions
|
@ -113,9 +113,12 @@ class Command(BaseCommand):
|
||||||
if parse_requests or both:
|
if parse_requests or both:
|
||||||
domain_requests = self.handle_portfolio_requests(portfolio, federal_agency)
|
domain_requests = self.handle_portfolio_requests(portfolio, federal_agency)
|
||||||
|
|
||||||
all_suborganizations.extend(suborganizations)
|
if suborganizations:
|
||||||
all_domains.extend(domains)
|
all_suborganizations.extend(suborganizations)
|
||||||
all_domain_requests.extend(domain_requests)
|
if all_domains:
|
||||||
|
all_domains.extend(domains)
|
||||||
|
if domain_requests:
|
||||||
|
all_domain_requests.extend(domain_requests)
|
||||||
except Exception as exec:
|
except Exception as exec:
|
||||||
self.failed_portfolios.add(federal_agency)
|
self.failed_portfolios.add(federal_agency)
|
||||||
logger.error(exec)
|
logger.error(exec)
|
||||||
|
|
|
@ -442,13 +442,14 @@ class TerminalHelper:
|
||||||
f.write(file_contents)
|
f.write(file_contents)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def colorful_logger(log_level, color, message):
|
def colorful_logger(log_level, color, message, exc_info=True):
|
||||||
"""Adds some color to your log output.
|
"""Adds some color to your log output.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
log_level: str | Logger.method -> Desired log level. ex: logger.info or "INFO"
|
log_level: str | Logger.method -> Desired log level. ex: logger.info or "INFO"
|
||||||
color: str | TerminalColors -> Output color. ex: TerminalColors.YELLOW or "YELLOW"
|
color: str | TerminalColors -> Output color. ex: TerminalColors.YELLOW or "YELLOW"
|
||||||
message: str -> Message to display.
|
message: str -> Message to display.
|
||||||
|
exc_info: bool -> Whether the log should print exc_info or not
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if isinstance(log_level, str) and hasattr(logger, log_level.lower()):
|
if isinstance(log_level, str) and hasattr(logger, log_level.lower()):
|
||||||
|
@ -462,4 +463,4 @@ class TerminalHelper:
|
||||||
terminal_color = color
|
terminal_color = color
|
||||||
|
|
||||||
colored_message = f"{terminal_color}{message}{TerminalColors.ENDC}"
|
colored_message = f"{terminal_color}{message}{TerminalColors.ENDC}"
|
||||||
log_method(colored_message)
|
log_method(colored_message, exc_info=exc_info)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue