We prefer to avoid top-posting on these lists but I'll go with the flow here...
<not tested, syntax is close but might have errors>
select *
from (select distinct equipment_id from log_table) a,
lateral get_log_data_for_equipment(equipment_id, 5)
then write the get_log_data_for_equipment function as dynamic sql substituting the desired limit value.
Not saying the above is going to be well performing but in terms of simplicity of the top-level query it scores high.
If you have an "equipment" table, which you should, replacing the select distinct with select should be considered. The presence of "distinct" (without 'on') is a code smell for me.
David J.