All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.swoval.logging.DefaultLogger Maven / Gradle / Ivy

There is a newer version: 2.1.12
Show newest version
package com.swoval.logging;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

class DefaultLogger {
  @SuppressWarnings("unchecked")
  static Logger get(final String className) {
    if (className != null) {
      try {
        final Class clazz = (Class) Class.forName(className);
        final Constructor constructor = clazz.getConstructor();
        return constructor.newInstance();
      } catch (final ClassNotFoundException
          | ClassCastException
          | NoSuchMethodException
          | InvocationTargetException
          | IllegalAccessException
          | InstantiationException e) {
        System.err.println("Couldn't instantiate an instance of " + className);
      }
    }
    return null;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy