Reputation: 268
I'm getting system logs from the server and feeding them to my widget which appends new logs to the log-container element. Logs look like this:
2017-06-0512:11:53.066|error[61f4cdd07abb]sequential(sequential)|interval(0)Error:...
I'm appending with jquery like this:
returnElement.append('<span class="message">' + log.message + ' </span><br>');
However, I would like to style these pipe symbols which act like delimiters in the logs |
Whats the best way to do this? Will probably have to wrap them with another span but I would like to avoid substringing each log.
Upvotes: 0
Views: 38
Reputation: 8423
You can do it with a RegExp, e.g.: msg.replace(/(\|)/g, '<span class="delimiter">$1</span>')
var msg = '2017-06-0512:11:53.066|error[61f4cdd07abb]sequential(sequential)|interval(0)Error:...';
document.write('<span>' + msg.replace(/(\|)/g, '<span class="delimiter">$1</span>') + '</span>');
.delimiter {
font-weight: bold;
color: green;
font-size: 16pt;
margin: 10px;
}
Upvotes: 1