Hello,
as far as I see write.chunk.logs() ignores the provided sub.li and tries to load moodle subs based on a directory which is not provided to write.chunk.logs (). All provided sub.li are overwritten.
My proposed solution would be to encase this line in a if clause. If sub.li is provided (not Null), we work with them and do not try to load moodle subs. Alternatively one might not provide sub.li but rather the sub.dir - in this case the load moodle funktion is executed (with this Parameter!) and tries to generate a new sub.li.
Does this make sense or do I miss something?