To create a log entry in WHMCS there's the LogActivity API ( https://developers.whmcs.com/api-reference/logactivity/ ), with following syntax:
$command = 'LogActivity';
$postData = array(
'description' => 'Activity log entry text goes here',
);
$results = localAPI($command, $postData;
print_r($results);
But there's also a shorter and faster way to do it:
$description' = 'Activity log entry text goes here';
$results = logActivity($description, 0);
print_r($results);
Or even shorter:
$results = logActivity('Activity log entry text goes here', 0);
print_r($results);
Surprisingly, this function exists but is not documented anywhere.