As parallel thought, I was thinking about adding timings on traceExit calls by creating a new Flow message factory (since you do not want to pay the price of calling System.nanos unless you want to.)
The nanos would be tracked in a new class, SimpleEntryTimestampMessage (instead of SimpleEntryMessage). This has has the benefit of not growing the public Logger API. You just need to create your Logger with the right factory. For the more general case aside from traceEnter/traceExit, I'm not sure how to do that. The nice thing about traceEnter is that it returns an object. All other Logger APIs return null. Gary On Mon, May 1, 2017 at 7:00 PM, Matt Sicker <[email protected]> wrote: > That use case reminds me a bit of Zipkin/Brave, though that's more so for > tracing between services than for local timing. I'm kind of wondering what > kind of log4j api you could make from this, though. > > On 1 May 2017 at 20:56, Gary Gregory <[email protected]> wrote: > > > Hi All: > > > > I find myself writing a lot of methods like: > > > > LOGGER.debug("Doing things with {}", foo); > > final StopWatch watch = StopWatch.createStarted(); > > // Do this > > // Do that > > // And then some > > watch.stop(); > > LOGGER.debug("Did foo things in {}", watch); > > > > Where the stop watch is Apache Commons Lang's > > https://commons.apache.org/proper/commons-lang/apidocs/ > > org/apache/commons/lang3/time/StopWatch.html > > > > Any thoughts on making things less verbose? > > > > Making watch.stop() return "this" would save a line but I'd have to clone > > StopWatch to do that which I do not mind. > > > > Gary > > > > -- > > E-Mail: [email protected] | [email protected] > > Java Persistence with Hibernate, Second Edition > > <https://www.amazon.com/gp/product/1617290459/ref=as_li_ > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459& > > linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8> > > > > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a= > > 1617290459> > > JUnit in Action, Second Edition > > <https://www.amazon.com/gp/product/1935182021/ref=as_li_ > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021& > > linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de4 > 18%22 > > > > > > > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a= > > 1935182021> > > Spring Batch in Action > > <https://www.amazon.com/gp/product/1935182951/ref=as_li_ > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951& > > linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B% > > 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action> > > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a= > > 1935182951> > > Blog: http://garygregory.wordpress.com > > Home: http://garygregory.com/ > > Tweet! http://twitter.com/GaryGregory > > > > > > -- > Matt Sicker <[email protected]> > -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition <https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459> JUnit in Action, Second Edition <https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021> Spring Batch in Action <https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
