use of io.vertx.core.impl.logging.Logger in project vert.x by eclipse.
the class CoreExamples method example18.
public void example18(String className, Exception exception) {
// Note -these classes are Java only
// You would normally maintain one static instance of Logger per Java class:
Logger logger = LoggerFactory.getLogger(className);
logger.info("something happened");
logger.error("oops!", exception);
}
use of io.vertx.core.impl.logging.Logger in project vert.x by eclipse.
the class BareCommand method configureFromSystemProperties.
/**
* This is used as workaround to retain the existing behavior of the Vert.x CLI and won't be executed
* in other situation.
*/
public static void configureFromSystemProperties(Object options, String prefix) {
Logger log = configureFromSystemProperties.get();
if (log == null) {
return;
}
Properties props = System.getProperties();
Enumeration<?> e = props.propertyNames();
// Uhh, properties suck
while (e.hasMoreElements()) {
String propName = (String) e.nextElement();
String propVal = props.getProperty(propName);
if (propName.startsWith(prefix)) {
String fieldName = propName.substring(prefix.length());
Method setter = getSetter(fieldName, options.getClass());
if (setter == null) {
log.warn("No such property to configure on options: " + options.getClass().getName() + "." + fieldName);
continue;
}
Class<?> argType = setter.getParameterTypes()[0];
Object arg;
try {
if (argType.equals(String.class)) {
arg = propVal;
} else if (argType.equals(int.class)) {
arg = Integer.valueOf(propVal);
} else if (argType.equals(long.class)) {
arg = Long.valueOf(propVal);
} else if (argType.equals(boolean.class)) {
arg = Boolean.valueOf(propVal);
} else if (argType.isEnum()) {
arg = Enum.valueOf((Class<? extends Enum>) argType, propVal);
} else {
log.warn("Invalid type for setter: " + argType);
continue;
}
} catch (IllegalArgumentException e2) {
log.warn("Invalid argtype:" + argType + " on options: " + options.getClass().getName() + "." + fieldName);
continue;
}
try {
setter.invoke(options, arg);
} catch (Exception ex) {
throw new VertxException("Failed to invoke setter: " + setter, ex);
}
}
}
}
Aggregations