Sounds like you're looking for display_log_message and variations on str_store_troop_name_link (such as str_store_faction_link). You can find usage details in the after action report generation code in my favorite of scripts: game_event_simulate_battle.
From header_operations.py:
str_store_troop_name_link = 2341 # (str_store_troop_name_link,<string_register>,<troop_id>),
str_store_party_name_link = 2342 # (str_store_party_name_link,<string_register>,<party_id>),
str_store_faction_name_link = 2343 # (str_store_faction_name_link,<string_register>,<faction_id>),
str_store_quest_name_link = 2344 # (str_store_quest_name_link,<string_register>,<faction_id>),