Yeah that's what I'm trying to do, grab the +5 item levels line.
However, what you said I already tried which is why I said grab the info without being at the forge / having artifact window open as that's the only time that information is available.
With that all in mind I just remembered about forcing the artifact window open through SocketInventoryItem(16) and then with a quick google search I found my solution.
Code:
UIParent:UnregisterEvent("ARTIFACT_UPDATE")
SocketInventoryItem(16)
for i = 1, C_ArtifactUI.GetNumRelicSlots() do
local isLocked = C_ArtifactUI.GetRelicLockedReason(i)
if isLocked then C_ArtifactUI.Clear() end
local name = C_ArtifactUI.GetRelicInfo(i)
local rank = C_ArtifactUI.GetRelicSlotRankInfo(i)
print("Relic ["..i.."] = "..name..", Rank ["..rank.."]")
end
C_ArtifactUI.Clear()
UIParent:RegisterEvent("ARTIFACT_UPDATE")