From cc70189513ccf01413f19aa25abfb1fd4a3b2e26 Mon Sep 17 00:00:00 2001 From: bsiggel Date: Tue, 31 Mar 2026 07:03:04 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20replace=20log=5Foperation()=20with=20ctx?= =?UTF-8?q?.logger=20in=20calendar=5Fsync=5Fall=5Fstep=20=E2=80=93=20compl?= =?UTF-8?q?y=20with=20INDEX.md=20logging=20standard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../advoware_cal_sync/calendar_sync_all_step.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/steps/advoware_cal_sync/calendar_sync_all_step.py b/src/steps/advoware_cal_sync/calendar_sync_all_step.py index 3999ffc..f6da55e 100644 --- a/src/steps/advoware_cal_sync/calendar_sync_all_step.py +++ b/src/steps/advoware_cal_sync/calendar_sync_all_step.py @@ -40,7 +40,7 @@ async def handler(input_data: Dict[str, Any], ctx: FlowContext) -> None: """ try: triggered_by = input_data.get('triggered_by', 'unknown') - log_operation('info', f"Calendar Sync All: Starting to emit events for oldest employees, triggered by {triggered_by}", context=ctx) + ctx.logger.info(f"Calendar Sync All: Starting to emit events for oldest employees, triggered by {triggered_by}") # Initialize Advoware service advoware = AdvowareService(ctx) @@ -48,7 +48,7 @@ async def handler(input_data: Dict[str, Any], ctx: FlowContext) -> None: # Fetch employees employees = await get_advoware_employees(advoware, ctx) if not employees: - log_operation('error', "Keine Mitarbeiter gefunden. All-Sync abgebrochen.", context=ctx) + ctx.logger.error("Keine Mitarbeiter gefunden. All-Sync abgebrochen.") raise RuntimeError("Keine Mitarbeiter gefunden. All-Sync abgebrochen.") redis_client = get_redis_client(ctx) @@ -74,17 +74,17 @@ async def handler(input_data: Dict[str, Any], ctx: FlowContext) -> None: return datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') sorted_list_str = ", ".join(f"{k} ({format_timestamp(employee_timestamps[k])})" for k in sorted_kuerzel) - log_operation('info', f"Calendar Sync All: Sorted employees by last synced: {sorted_list_str}", context=ctx) + ctx.logger.info(f"Calendar Sync All: Sorted employees by last synced: {sorted_list_str}") # Calculate number to sync: ceil(N / 10) num_to_sync = math.ceil(len(sorted_kuerzel) / 1) - log_operation('info', f"Calendar Sync All: Total employees {len(sorted_kuerzel)}, syncing {num_to_sync} oldest", context=ctx) + ctx.logger.info(f"Calendar Sync All: Total employees {len(sorted_kuerzel)}, syncing {num_to_sync} oldest") # Emit for the oldest num_to_sync employees, if not locked emitted_count = 0 for kuerzel in sorted_kuerzel[:num_to_sync]: if not set_employee_lock(redis_client, kuerzel, triggered_by, ctx): - log_operation('info', f"Calendar Sync All: Sync already active for {kuerzel}, skipping", context=ctx) + ctx.logger.info(f"Calendar Sync All: Sync already active for {kuerzel}, skipping") continue # Emit event for this employee @@ -95,11 +95,11 @@ async def handler(input_data: Dict[str, Any], ctx: FlowContext) -> None: "triggered_by": triggered_by } }) - log_operation('info', f"Calendar Sync All: Emitted event for employee {kuerzel} (last synced: {format_timestamp(employee_timestamps[kuerzel])})", context=ctx) + ctx.logger.info(f"Calendar Sync All: Emitted event for employee {kuerzel} (last synced: {format_timestamp(employee_timestamps[kuerzel])})") emitted_count += 1 - log_operation('info', f"Calendar Sync All: Completed, emitted {emitted_count} events", context=ctx) + ctx.logger.info(f"Calendar Sync All: Completed, emitted {emitted_count} events") except Exception as e: - log_operation('error', f"Fehler beim All-Sync: {e}", context=ctx) + ctx.logger.error(f"Fehler beim All-Sync: {e}") raise