package com.palacesun.engine.logging;

import com.palacesun.engine.event.JdbcEventListener;
import com.palacesun.engine.spy.P6Factory;
import com.palacesun.engine.spy.P6LoadableOptions;
import com.palacesun.engine.spy.option.P6OptionsRepository;
import java.util.Iterator;
import java.util.ServiceLoader;

public class P6LogFactory implements P6Factory {
   private static ServiceLoader<LoggingEventListener> customLoggingEventListener = ServiceLoader.load(LoggingEventListener.class, P6LogFactory.class.getClassLoader());

   public JdbcEventListener getJdbcEventListener() {
      Iterator<LoggingEventListener> iterator = customLoggingEventListener.iterator();
      return (JdbcEventListener)(iterator.hasNext() ? (JdbcEventListener)iterator.next() : LoggingEventListener.INSTANCE);
   }

   public P6LoadableOptions getOptions(P6OptionsRepository optionsRepository) {
      return new P6LogOptions(optionsRepository);
   }
}
