[slf4j-dev] Better printing method signatures?
Niclas Hedhman
niclas at hedhman.org
Fri Jun 17 06:36:00 CEST 2005
On Friday 17 June 2005 04:30, Ceki Gülcü wrote:
> I think nhD and nhE are ambiguous. For example, the following statement
> will not compile.
>
> debug("hello", new Object[] {}, new Object[] {});
>
> Moreover, I fail to see a need for nhD or nhE, if you have nhC.
Slight misunderstanding. I should have been more clear :o)
I was not talking in terms of method signatures, but in terms of possible
arguments for the generic method signatures that you propose, how they are
handled (i.e runtime) and how we are going to document it in a 'friendly'
manner (i.e. taking into account how IDEs do javadoc popups, code completions
and such).
You proposed;
void debug(Object msg);
void debug(Object msg, Object param1);
void debug(Object msg, Object param1, Object param2);
So, I can feed that with any arbitrary 1 to 3 arguments of any non-primitive
types.
Read nhA as;
String message = "abc";
Object arg1 = new SomeArbitraryObject();
Throwable exc = new NiclasNotClearEnoughException();
logger.debug( message, arg1, exc );
and for instance nhE as;
String message = "abc";
Object arg1 = new SomeArbitraryObject();
Object[] array = new Object[]{ "abc", "def" };
logger.debug( message, array, arg1 );
and so forth...
Hope this is as explicit as it can get.
Spending a bit more thinking on it, I think I am in the camp of "very explicit
method signatures" and compile time determination of behaviour, but possibly
reduce to the 'common cases' for the named methods, and a few more in
'variable level' methods.
For instance;
debug( String message );
debug( String message, String arg );
info( String message );
info( String message, String arg );
warning( String message );
warning( String message, String arg );
error( String message );
error( String message, String arg );
error( String message, String arg, Throwable exc );
log( int level, String message );
log( int level, String message, String arg1 );
log( int level, String message, String arg1, String arg2 );
log( int level, String message, Throwable exc );
log( int level, String message, String arg1, Throwable exc );
log( int level, String message, String arg1, String arg2, Throwable exc );
log( int level, String message, Object[] args );
log( int level, String message, Object[] args, Throwable exc );
i.e. Principle of "Simple stuff simple and complex stuff possible".
But then again, I am probably in the camp that would only use the "log()"
methods, and have my own facade with more explicit names.
Cheers
Niclas
More information about the slf4j-dev
mailing list