Skip to content

Commit d2e01ad

Browse files
committed
processor_content_modifier: logs: do not fail if keys are not found
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 30a04be commit d2e01ad

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

plugins/processor_content_modifier/cm_logs.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ static int run_action_insert(struct content_modifier_ctx *ctx,
404404
ret = cfl_kvlist_insert_string_s(kvlist, key, cfl_sds_len(key), value, cfl_sds_len(value),
405405
CFL_FALSE);
406406
if (ret != 0) {
407-
printf("Failed to insert key: %s\n", key);
407+
flb_plg_debug(ctx->ins, "[action: insert] failed to insert key: %s", key);
408408
return -1;
409409
}
410410
return 0;
@@ -451,7 +451,10 @@ static int run_action_delete(struct content_modifier_ctx *ctx,
451451
return 0;
452452
}
453453

454-
return -1;
454+
flb_plg_debug(ctx->ins, "[action: delete] key '%s' not found", key);
455+
456+
/* if the kvpair was not found, it's ok, we return zero */
457+
return 0;
455458
}
456459

457460
static int run_action_rename(struct content_modifier_ctx *ctx,
@@ -465,7 +468,8 @@ static int run_action_rename(struct content_modifier_ctx *ctx,
465468
/* if the kv pair already exists, remove it from the list */
466469
kvpair = cfl_object_kvpair_get(obj, key);
467470
if (!kvpair) {
468-
return -1;
471+
flb_plg_debug(ctx->ins, "[action: rename] key '%s' not found", key);
472+
return 0;
469473
}
470474

471475
tmp = kvpair->key;

0 commit comments

Comments
 (0)