/*
 * (C) Copyright IBM Corporation 2016
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ibm.ws.microprofile.sample.conference.vote.utils;

import java.lang.reflect.Method;
import java.util.Arrays;
import javax.annotation.Priority;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;

@Log
@Interceptor
@Priority(Logger.PRIORITY)
public class Logger {
	
	static final int PRIORITY = 3000;
	 
	@AroundInvoke
	public Object Log(InvocationContext context) throws Exception {
	    Method method = context.getMethod();
	    String clazz = method.getDeclaringClass().getName();
	    String mthd =  clazz + ":" + method.getName();
     	String parms = Arrays.toString(context.getParameters());
		
		
	       try {
	           Object result = context.proceed();
	           System.out.println( "Call to " + mthd + "(" + parms + ") returned " + result);
	           return result;
	        }
	        catch (Exception e) {
               System.out.println("Call to " + mthd + "(" + parms + ") threw " + e.toString() );
	           throw e;
	        }
	}

}

@@ -939,18 +939,17 @@
 ogger %7B%0A
-%09
 %0A
+
 %09static 
@@ -979,11 +979,9 @@
 00;%0A
-%09 
 %0A
+
 %09@Ar
@@ -1057,20 +1057,17 @@
 tion %7B%0A%09
-    
+%09
 Method m
@@ -1092,28 +1092,25 @@
 tMethod();%0A%09
-    
+%09
 String clazz
@@ -1151,20 +1151,17 @@
 ame();%0A%09
-    
+%09
 String m
@@ -1165,17 +1165,16 @@
 g mthd =
- 
  clazz +
@@ -1198,21 +1198,17 @@
 Name();%0A
-     
+%09
 %09String 
@@ -1261,40 +1261,20 @@
 ));%0A
-%09%09
 %0A%09%09
-%0A%09       try %7B%0A%09           
+try %7B%0A%09%09%09
 Obje
@@ -1305,27 +1305,18 @@
 eed();%0A%09
-           
+%09%09
 System.o
@@ -1326,17 +1326,16 @@
 println(
- 
 %22Call to
@@ -1386,27 +1386,18 @@
 sult);%0A%09
-           
+%09%09
 return r
@@ -1408,26 +1408,10 @@
 t;%0A%09
-        %7D%0A%09       
+%09%7D
  cat
@@ -1433,23 +1433,11 @@
 ) %7B%0A
-               
+%09%09%09
 Syst
@@ -1514,24 +1514,14 @@
 ng()
- 
 );%0A%09
-           
+%09%09
 thro
@@ -1530,16 +1530,9 @@
 e;%0A%09
-        
+%09
 %7D%0A%09%7D

Improve formatting.