Yes, I understand your concern, ideally the ui stuff should be stripped from this function and the remaining code moved to another class together with the string fetching functions (uavo hash etc). This would then be used by both the logger and kml exporter.
I'm unsure about the ideal location for this new helper class, maybe uavalk, coreplugin or even the utils library?