jokade / slogging

A Typesafe-logging (and slf4j) compatible logging library based on macros for Scala/JVM, Scala.js, and Scala Native
MIT License
50 stars 11 forks source link

how to make "collapsed" TRACE logs default ? #37

Closed jhegedus42 closed 5 years ago

jhegedus42 commented 5 years ago

Hi,

Here is how it is possible to collapse TRACE logs, perhaps using something like this : https://mariusschulz.com/blog/advanced-javascript-logging-using-console-group

Something like this : image

Is it possible to do the same with slogger ?

For me a trace looks like this : image But it would be much nicer to have these "TRACE"-s already folded by default , like this : image

jhegedus42 commented 5 years ago

answer:

Put the following into the JS console before executing the code :

console.oldTrace=console.trace
f =  function(x) { console.groupCollapsed(x);console.oldTrace(x); console.groupEnd()}
console.trace=f

Then you get:

image

vanowm commented 2 years ago

@jhegedus42 Since trace can accept multiple arguments, it's better use apply instead, also it looks better if it doesn't show same arguments twice (typescript friendly version)

{
  const oldTrace= console.trace;
  console.trace = (...args) => { console.groupCollapsed.apply(console, args); oldTrace(""); console.groupEnd()};
}