package com.github.fluxw42.thistothat.converter.audio;

import com.github.fluxw42.thistothat.converter.ConversionException;
import com.github.fluxw42.thistothat.converter.ConversionProgressListener;
import com.github.fluxw42.thistothat.converter.Converter;
import com.github.fluxw42.thistothat.jave.AudioAttributes;
import com.github.fluxw42.thistothat.jave.Encoder;
import com.github.fluxw42.thistothat.jave.EncoderException;
import com.github.fluxw42.thistothat.jave.EncoderProgressListener;
import com.github.fluxw42.thistothat.jave.EncodingAttributes;
import com.github.fluxw42.thistothat.jave.MultimediaInfo;

import java.io.File;

/**
 * Date: 2/5/16 - 3:51 PM
 *
 * @author Jeroen Meulemeester
 */
public class AudioConverter extends Converter {

    /**
     * The expected audio format
     */
    private final AudioFormat format;

    /**
     * Create a new audio converter to convert the input file to the given {@link AudioFormat}
     *
     * @param inputFile  The input audio file
     * @param outputFile The output audio file
     * @param format     The expected output format
     */
    public AudioConverter(final File inputFile, final File outputFile, final AudioFormat format) {
        super(inputFile, outputFile);
        this.format = format;
    }

    /**
     * {@inheritDoc}
     */
    public void convert(final ConversionProgressListener listener) throws ConversionException {
        try {
            final EncodingAttributes attributes = new EncodingAttributes();
            attributes.setAudioAttributes(new AudioAttributes());
            attributes.setFormat(this.format.getName());

            final Encoder encoder = new Encoder();
            encoder.encode(
                    getInputFile(),
                    getOutputFile(),
                    attributes,
                    mapListener(listener)
            );
        } catch (EncoderException e) {
            throw new ConversionException(getInputFile(), getOutputFile(), e);
        }
    }

    /**
     * Map the given {@link ConversionProgressListener} to a JAVE {@link EncoderProgressListener}
     *
     * @param listener The {@link ConversionProgressListener}
     * @return The {@link EncoderProgressListener}
     */
    private EncoderProgressListener mapListener(final ConversionProgressListener listener) {
        return new EncoderProgressListener() {
            public void sourceInfo(MultimediaInfo multimediaInfo) {

            }

            public void progress(int i) {
                if (listener != null) {
                    listener.state(i);
                }
            }

            public void message(String s) {

            }
        };
    }

}

@@ -628,16 +628,81 @@
 io.File;
+%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;
 %0A%0A/**%0A *
@@ -808,24 +808,175 @@
 onverter %7B%0A%0A
+    /**%0A     * The logger for class AudioConverter%0A     */%0A    private static final Logger logger = Logger.getLogger(AudioConverter.class.getName());%0A%0A
     /**%0A    
@@ -2584,16 +2584,78 @@
 ener() %7B
+%0A%0A            /**%0A             * %7B@inheritDoc%7D%0A             */
 %0A       
@@ -2662,24 +2662,30 @@
      public 
+final 
 void sourceI
@@ -2725,42 +2725,255 @@
 ) %7B%0A
-%0A            %7D%0A%0A            public
+                if (logger.isLoggable(Level.INFO)) %7B%0A                    logger.log(Level.INFO, String.valueOf(multimediaInfo));%0A                %7D%0A            %7D%0A%0A            /**%0A             * %7B@inheritDoc%7D%0A             */%0A            public final
  voi
@@ -3096,32 +3096,93 @@
 %0A            %7D%0A%0A
+            /**%0A             * %7B@inheritDoc%7D%0A             */%0A
             publ
@@ -3180,24 +3180,30 @@
      public 
+final 
 void message
@@ -3214,13 +3214,142 @@
 ing 
-s) %7B%0A
+message) %7B%0A                if (logger.isLoggable(Level.FINE)) %7B%0A                    logger.log(Level.FINE, message);%0A                %7D
 %0A   
@@ -3351,32 +3351,33 @@
 %7D%0A            %7D%0A
+%0A
         %7D;%0A    %7D

Add more logging to AudioConverter class