/*
 * Copyright 2015 Fidesmo AB
 *
 * 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.fidesmo.gradle.plugin;

import java.io.IOException;
import java.util.List;
import java.util.ArrayList;

import com.fidesmo.sec.utils.Hex;
import nordpol.IsoCard;
import nordpol.OnCardErrorListener;

/** Wrap an IsoCard so that all transmitted APDUs are logged */

public class LoggingCard implements IsoCard {

    IsoCard underlying;

    public LoggingCard(IsoCard underlying) {
        this.underlying = underlying;
    }

    public void addOnCardErrorListener(OnCardErrorListener listener) {
        underlying.addOnCardErrorListener(listener);
    }

    public void removeOnCardErrorListener(OnCardErrorListener listener) {
        underlying.removeOnCardErrorListener(listener);
    }

    public boolean isConnected() {
        return underlying.isConnected();
    }

    public void connect() throws IOException {
        underlying.connect();
    }

    public void close() throws IOException {
        underlying.close();
    }

    public int getTimeout() {
        return underlying.getTimeout();
    }

    public void setTimeout(int t) {
        underlying.setTimeout(t);
    }

    public int getMaxTransceiveLength() throws IOException {
        return underlying.getMaxTransceiveLength();
    }

    public byte[] transceive(byte[] command) throws IOException {
        System.out.println("Send to card: " + Hex.encodeHex(command));
        byte[] response = underlying.transceive(command);
        System.out.println("Received from card: " + Hex.encodeHex(response));
        return response;
    }

    public List<byte[]> transceive(List<byte[]> commands) throws IOException {
        List<byte[]> responses = new ArrayList<byte[]>(commands.size());
        for (byte[] command: commands) {
            responses.add(transceive(command));
        }
        return responses;
    }
}

@@ -802,16 +802,74 @@
 tener;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A
 /** Wrap
@@ -995,16 +995,35 @@
 erlying;
+%0A    Logger logger;
 %0A%0A    pu
@@ -1057,24 +1057,24 @@
 derlying) %7B%0A
-
         this
@@ -1095,24 +1095,92 @@
 underlying;%0A
+        this.logger = LoggerFactory.getLogger(%22transaction-trace%22);%0A
     %7D%0A%0A    p
@@ -2037,34 +2037,27 @@
         
-System.out.println
+logger.info
 (%22Send t
@@ -2163,26 +2163,19 @@
     
-System.out.println
+logger.info
 (%22Re

Change logger to use sl4j