Skip to content

Commit

Permalink
applies format and improve fault tolerancy for creation logs on contr…
Browse files Browse the repository at this point in the history
…ollers
  • Loading branch information
GabrielBarberini committed Nov 16, 2024
1 parent e07e1c4 commit c6ac1d3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
7 changes: 6 additions & 1 deletion lib/controllers/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ async def create_env(env: Env) -> Union[EnvCreated, HTTPException]:
else:
return EnvCreated(env_id=env_repo.env_id)
finally:
env_id = (
getattr(env_repo, 'env_id', 'unknown')
if env_repo
else 'unknown'
)
if env_repo:
logger.info(
f"Call to controllers.environment.create_env completed for Env {env_repo.env_id}"
f"Call to controllers.environment.create_env completed for Env {env_id}"
)

@staticmethod
Expand Down
6 changes: 5 additions & 1 deletion lib/controllers/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ async def create_flight(
else:
return FlightCreated(flight_id=flight_repo.flight_id)
finally:
flight_id = getattr(flight_repo, 'flight_id', 'unknown') if flight_repo else 'unknown'
flight_id = (
getattr(flight_repo, 'flight_id', 'unknown')
if flight_repo
else 'unknown'
)
logger.info(
f"Call to controllers.flight.create_flight completed for Flight {flight_id}"
)
Expand Down
7 changes: 6 additions & 1 deletion lib/controllers/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@ async def create_motor(
else:
return MotorCreated(motor_id=motor_repo.motor_id)
finally:
motor_id = (
getattr(motor_repo, 'motor_id', 'unknown')
if motor_repo
else 'unknown'
)
if motor_repo:
logger.info(
f"Call to controllers.motor.create_motor completed for Motor {motor_repo.motor_id}"
f"Call to controllers.motor.create_motor completed for Motor {motor_id}"
)

@staticmethod
Expand Down
7 changes: 6 additions & 1 deletion lib/controllers/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ async def create_rocket(
else:
return RocketCreated(rocket_id=rocket_repo.rocket_id)
finally:
rocket_id = (
getattr(rocket_repo, 'rocket_id', 'unknown')
if rocket_repo
else 'unknown'
)
if rocket_repo:
logger.info(
f"Call to controllers.rocket.create_rocket completed for Rocket {rocket_repo.rocket_id}"
f"Call to controllers.rocket.create_rocket completed for Rocket {rocket_id}"
)

@staticmethod
Expand Down

0 comments on commit c6ac1d3

Please sign in to comment.