// Path: src/main/java/org/arbeitspferde/groningen/utility/logstream/OutputLogStream.java
// @NotThreadSafe
// public interface OutputLogStream extends Flushable, Closeable {
//   public void write(final Message message) throws IOException;
// }


import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import org.arbeitspferde.groningen.proto.Event;
import org.arbeitspferde.groningen.utility.logstream.OutputLogStream;
import org.arbeitspferde.groningen.utility.logstream.OutputLogStreamFactory;
import org.arbeitspferde.groningen.utility.logstream.OutputLogStreamFactory.Specification;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
        });

    final SafeProtoLogger<Event.EventEntry> logger =
        new SafeProtoLogger<>(stream, loggerName);

    yieldTimer(flushIntervalSeconds, loggerName, logger);

    return logger;
  }

  /**
   * Create a timer that automatically flushes the RecordIO stream.
   *
   * No hard reference needs to be held onto the {@link Timer} per its Javadoc.
   *
   * @param flushIntervalSeconds See {@link #newEventEntryLogger(String, int, long, int, String)}.
   * @param loggerName See {@link #newEventEntryLogger(String, int, long, int, String)}.
   * @param logger A {@link SafeProtoLogger}.
   *
   * @return The {@link Timer} that manages the automatic flushing.
   */
  @VisibleForTesting
  Timer yieldTimer(final int flushIntervalSeconds, final String loggerName,
      final SafeProtoLogger<?> logger) {
    Preconditions.checkNotNull(loggerName, "loggerName may not be null.");
    Preconditions.checkNotNull(logger, "stream may not be null.");

    final Timer flushEventTimer = timerProvider.get();

    if (flushIntervalSeconds > 0) {
// Path: src/main/java/org/arbeitspferde/groningen/utility/logstream/OutputLogStream.java
// @NotThreadSafe
// public interface OutputLogStream extends Flushable, Closeable {
//   public void write(final Message message) throws IOException;
// }


// Path: src/main/java/org/arbeitspferde/groningen/eventlog/SafeProtoLoggerFactory.java
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import org.arbeitspferde.groningen.proto.Event;
import org.arbeitspferde.groningen.utility.logstream.OutputLogStream;
import org.arbeitspferde.groningen.utility.logstream.OutputLogStreamFactory;
import org.arbeitspferde.groningen.utility.logstream.OutputLogStreamFactory.Specification;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;

        });

    final SafeProtoLogger<Event.EventEntry> logger =
        new SafeProtoLogger<>(stream, loggerName);

    yieldTimer(flushIntervalSeconds, loggerName, logger);

    return logger;
  }

  /**
   * Create a timer that automatically flushes the RecordIO stream.
   *
   * No hard reference needs to be held onto the {@link Timer} per its Javadoc.
   *
   * @param flushIntervalSeconds See {@link #newEventEntryLogger(String, int, long, int, String)}.
   * @param loggerName See {@link #newEventEntryLogger(String, int, long, int, String)}.
   * @param logger A {@link SafeProtoLogger}.
   *
   * @return The {@link Timer} that manages the automatic flushing.
   */
  @VisibleForTesting
  Timer yieldTimer(final int flushIntervalSeconds, final String loggerName,
      final SafeProtoLogger<?> logger) {
    Preconditions.checkNotNull(loggerName, "loggerName may not be null.");
    Preconditions.checkNotNull(logger, "stream may not be null.");

    final Timer flushEventTimer = timerProvider.get();

    if (flushIntervalSeconds > 0) {
      flushEventTimer.schedule(new TimerTask() {