有没有办法在更新Woocommerce产品时跟踪循环中的函数活动?

I am seeking a method by code how to trace an activity of a function when updating product info in a loop.

For example, lets say we have 4000 products at our store and we want to update the price for all products using a defined filter.

The code to update the prices is for instance the following:

private function set_custom_price($product) {
if (!$product->exists()) {
    return false;
}

$product_price = $product->get_regular_price();

if (($product_price > 0) && ($product_price < 401)) {
    $product->set_regular_price(ceil(($product_price + ($product_price*(0.5)))/10) *10-1);
} elseif (($product_price > 400) && ($product_price < 801)) {
    $product->set_regular_price(ceil(($product_price + 120)/10) *10-1);
} elseif (($product_price > 800) && ($product_price < 1101)) {
    $product->set_regular_price(ceil(($product_price + 150)/10) *10-1);
} elseif (($product_price > 1100) && ($product_price < 1601)) {
    $product->set_regular_price(ceil(($product_price + 200)/10) *10-1);
} elseif (($product_price > 1600) && ($product_price < 2001)) {
    $product->set_regular_price(ceil(($product_price + 220)/10) *10-1);
} elseif (($product_price > 2000) && ($product_price < 5001)) {
    $product->set_regular_price(ceil(($product_price + ($product_price*(0.15)))/10) *10-1);
}

$product->save();

// HERE SOME CODE NEEDED TO REGISTER TRACE??
}

How would it be possible to make sure that in each round (for each product the function updates) an ID or a name value of the editting function (in this case "set_custom_price") is stored with the update of the given product?

The reason why this is important is because this updating script is a part of a cron chain-scheduled tasks. In case of an unknown interruption, the entire process is restarted from the beginning and there is a risk that prices of some products will be updated twice or even more times. I am seeking a security mechanism, by which it would be in each run possible to identify already editted products by the same function and skip them in case the script crashes.

Would anyone have any ideas?