[slf4j-dev] Logger.debug(String, Object[])?
Curt Arnold
carnold at houston.rr.com
Fri Aug 5 17:46:31 CEST 2005
On Aug 5, 2005, at 10:14 AM, Niclas Hedhman wrote:
> On Friday 05 August 2005 17:29, Ceki Gülcü wrote:
>
>> The Object[] param form has been requested very frequently. It's
>> quite
>> a reasonable request. As such, you can expect method accepting
>> Object[] as parameter to be added in the near future.
>>
>
> Didn't we at some point say that
>
> void debug( String format, Object args );
>
> can quite easily take the
>
> logger.debug( "{} : {} : {}", new Object[] { arg1, arg2, arg3 } );
>
> and therefor the proposed signature would not be needed, but
> support in
> runtime...
Yes, but that changes a compile-time determination of the developers
intent into a run-time determination. With two distinct signatures,
you can distinguish between:
Object foo = new Integer(5);
if (useArray) {
foo = new Object[] { "Hello, World", "Goodnight, Gracie" };
}
logger.debug("foo = {}", foo);
and
Object[] salutations = new Object[] { "Hello, World", "Goodnight,
Gracie" };
logger.debug("Morning greeting = {}, Evening greeting = {}",
saluations);
If you only have one signature, the body would have no way to know
whether the developer had intended it be to treated as one parameter
or many.
More information about the slf4j-dev
mailing list