0

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.

1 Answer 1

1

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;
}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.