logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: New traceEntry code
Date Mon, 08 Feb 2016 17:29:16 GMT
First, this probably should be on the dev list, not the users list.

Second, the sample methods you provided all take a method parameter. Log4j’s don’t as
they rely on the caller’s location information to get that, so traceExit doesn’t take
a method parameter as you show below.

I’ll add the @since tags and make sure more unit tests are present.

Ralph


> On Feb 8, 2016, at 10:17 AM, Gary Gregory <garydgregory@gmail.com> wrote:
> 
> Hi All:
> 
> The pattern I've had to implement for our product is close to what this
> does, but not quite, so I'd like to propose changes.
> 
> The key part is for the new traceEntry methods to return the String message
> it built so I can reuse it in the traceExit() call. This is how I do it now:
> 
> public int doFoo(int a, int b) {
>  final String method = traceEntry("doFoo(a=%,d, b=%,d", a, b);
>  // do Foo impl
>  int result = ...
>  return traceExit(method, result);
> }
> 
> This allows the Entry/Exit log events to match nicely, especially in our
> multi-threaded use cases. It's easier to tell which exit matches which
> entry. You do not want to compute the method String more than once of
> course.
> 
> (I use the String.format() message factory to get nice looking numbers, and
> so on. We allow that to be set up at the logger level, which is nice.)
> 
> I've had to cookup my own my own traceEntry/traceExit, otherwise the code
> would be logger.traceEntry(...).
> 
> The verbiage I use is also different: I use a verb: "Enter", as opposed to
> the noun "entry", which looks really weird in English to me. "Entry
> methodName"? That does not sound good to me "Entry of methodName" OK. For
> me it's "Enter methodName..." and "Exit methodName". Sentences start with a
> cap too.
> 
> It's too late to change the API names but the wording should be fixed
> (calling it broken is my opinion of course) or configurable.
> 
> The new methods are missing @since Javadoc tags
> 
> I could only find a unit for 1 of the new APIs, did I miss the others?
> 
> I'll experiment unless I hear howls of horror...
> 
> Gary
> -- 
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message