feat: Add logging utility for calendar sync operations and enhance error handling
This commit is contained in:
@@ -1056,6 +1056,11 @@ async def handler(input_data: Dict[str, Any], ctx: FlowContext) -> None:
|
||||
|
||||
return {'status': 200, 'body': {'status': 'completed', 'kuerzel': kuerzel}}
|
||||
|
||||
except Exception as e:
|
||||
log_operation('error', f"Sync failed for {kuerzel}: {e}", context=ctx)
|
||||
log_operation('info', f"Handler duration (failed): {time.time() - start_time}", context=ctx)
|
||||
return {'status': 500, 'body': {'error': str(e)}}
|
||||
|
||||
finally:
|
||||
# Always close resources to prevent memory leaks
|
||||
if service is not None:
|
||||
@@ -1068,11 +1073,6 @@ async def handler(input_data: Dict[str, Any], ctx: FlowContext) -> None:
|
||||
redis_client.close()
|
||||
except Exception as e:
|
||||
log_operation('debug', f"Error closing Redis client: {e}", context=ctx)
|
||||
|
||||
except Exception as e:
|
||||
log_operation('error', f"Sync failed for {kuerzel}: {e}", context=ctx)
|
||||
log_operation('info', f"Handler duration (failed): {time.time() - start_time}", context=ctx)
|
||||
return {'status': 500, 'body': {'error': str(e)}}
|
||||
finally:
|
||||
|
||||
# Ensure lock is always released
|
||||
clear_employee_lock(redis_client, kuerzel, ctx)
|
||||
|
||||
Reference in New Issue
Block a user