super(messageLogger.projectCode());
logger = Logger.getLogger(category);
}
public Object invoke(final Object proxy, final Method method, Object[] args) throws Throwable {
final Message message = method.getAnnotation(Message.class);
if (message == null) {
// nothing to do...
return null;
}
final Annotation[][] parameterAnnotations = method.getParameterAnnotations();
final Log logMessage = method.getAnnotation(Log.class);
if (logMessage != null) {
try {
// See if it's a basic logger method
if (method.getDeclaringClass().equals(BasicLogger.class)) {
// doesn't cover overrides though!
return method.invoke(logger, args);
}
// it's a log message
final Logger.Level level = logMessage.level();
if (logger.isEnabled(level)) {
String formatString = getFormatString(message);
if (formatString == null) {
return null;
}
ArrayList<Object> newArgs = new ArrayList<Object>();
Throwable cause = extractCause(parameterAnnotations, args, newArgs);
final Message.Format format = message.format();
switch (format) {
case PRINTF: {
logger.logf(level, cause, formatString, newArgs.toArray());
return null;
}