I saw someone writing a java LOG API like the code unerneath. The idea is that the Client does not have to invoke LogUtil.getInstance() every time. But my feelings are this is not idiomatic java?
public class LogUtil{
private static LogUtil instance;
private Object current;//some Logger
private static LogUtil getInstance(){
if(instance == null){
instance = new LogUtil();
}
return instance;
}
private static void debug(String text){
}
public static LogUtil init(){
//dosomething with
// getInstance().current;
return getInstance();
}
public static LogUtil logSomething(String text){
//dosomething with
// getInstance().current;
return getInstance();
}
public static LogUtil anotherMethod(String text){
//dosomething with
// getInstance().current;
return getInstance();
}
}
What are the arguments against such a design (making every method static)?