[slf4j-dev] Better printing method signatures?

Ceki Gülcü listid at qos.ch
Wed Jun 15 22:30:39 CEST 2005


Hello all,

The current SLF4J API has 4 printing methods per level. For example,
for the DEBUG level, we have:

  void debug(Object msg);
  void debug(Object parameterizedMsg, Object param1);
  void debug(Object msg, Throwable t);
  void debug(String parameterizedMsg, Object param1, Object param2);

The second and third methods taking two methods can be little
confusing since a Throwable is also an Object. Not every programmer
knows the details of Java overloading rules.

The fourth method's first parameter is a String while it is an Object
for the first three methods.

I am thinking of reducing the set to 3 as follows:

  void debug(Object msg);
  void debug(Object msg, Object param1);
  void debug(Object msg, Object param1, Object param2);

In this case, each overloaded method has a different number of
parameters, so the overloading is easier to follow.

For the first variant (with one parameter), if the passed object is an
Exception, we can print its stack trace.

For the second variant (2 parameters), if the second object is an
Exception, we can print the message (1st object) followed by an
exception trace of the second object. If the second object is not an
exception, we would perform parameter substitution.

Any better ideas? Comments?


-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/





More information about the slf4j-dev mailing list