I have gone about this via namespacing my debug logs so it assigns a colour based on that namespace.
debug('cache:set', {}) // cache:set +1ms {}
The namespace here being cache which is mapped against an array of colours using the following code...
let log = 'cache:set'; let colors = []; const hash = data => { let hash = 0; for (let index = 0; index < data.length; index++) { hash = ((hash << 5) + hash + data.charCodeAt(index)) & 0xffffffff; } return hash; }; let namespace = log.substring(0, log.indexOf(':')); let color = colors[Math.abs(hash(namespace)) % colors.length];
This way cache logs are always shown in the same colour allowing you to visually identify them.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have gone about this via namespacing my debug logs so it assigns a colour based on that namespace.
The namespace here being cache which is mapped against an array of colours using the following code...
This way cache logs are always shown in the same colour allowing you to visually identify them.