Sorry, but this is not the way. It's like saying, "but I am escaping my inputs on sql with my function"... instead of doing the right thing.
The equivalent code is really not that hard:
const span = document.createElement('span')
span.setAttribute('class', 'fi fi'+msg.cc)
span.setAttribute('title', msg.cc)
col1.appendChild(span)
col1.appendChild(document.createTextNode(msg.src))
col2.textContent = msg.proto
let code = document.createElement('code')
code.textContent = msg.u
col3.appendChild(code)
code = code.cloneNode(true)
code.textContent = msg.p
col4.appendChild(code)
or something in these lines.. you get the idea