package com.jivesoftware.os.miru.plugin.solution;

import com.jivesoftware.os.mlogger.core.MessageFormatter;
import com.jivesoftware.os.mlogger.core.MetricLogger;
import com.jivesoftware.os.mlogger.core.MetricLoggerFactory;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author jonathan.colt
 */
public class MiruSolutionLog {

    private static final MetricLogger METRIC_LOGGER = MetricLoggerFactory.getLogger();

    private final MiruSolutionLogLevel level;
    private final List<String> log = new ArrayList<>();

    public MiruSolutionLog(MiruSolutionLogLevel level) {
        this.level = level;
    }

    public MiruSolutionLogLevel getLevel() {
        return level;
    }

    public boolean isLogLevelEnabled(MiruSolutionLogLevel checkLevel) {
        return level.ordinal() <= checkLevel.ordinal();
    }

    public void log(MiruSolutionLogLevel atLevel, String message) {
        if (isLogLevelEnabled(atLevel)) {
            log.add(System.currentTimeMillis() + " " + message);
            METRIC_LOGGER.debug(message);
        } else {
            METRIC_LOGGER.trace(message);
        }
    }

    public void log(MiruSolutionLogLevel atLevel, String message, Object... args) {
        if (isLogLevelEnabled(atLevel)) {
            log.add(System.currentTimeMillis() + " " + MessageFormatter.format(message, args));
            METRIC_LOGGER.debug(message, args);
        } else {
            METRIC_LOGGER.trace(message, args);
        }
    }

    public List<String> asList() {
        return log;
    }

    public void clear() {
        log.clear();
    }

    public void append(MiruSolutionLog append) {
        log.addAll(append.asList());
    }
}

@@ -273,15 +273,63 @@
 t;%0A%0A
+import static com.sun.tools.doclint.Entity.times;%0A%0A
 /**%0A
- *%0A
  * @
@@ -574,16 +574,74 @@
 ist%3C%3E();
+%0A    private volatile long lastLoggedTimestampMillis = -1;
 %0A%0A    pu
@@ -1051,38 +1051,42 @@
 %7B%0A            lo
-g.add(
+ng time = 
 System.currentTi
@@ -1091,28 +1091,214 @@
 TimeMillis()
- + %22
+;%0A            long delta = lastLoggedTimestampMillis == -1 ? 0L : time - lastLoggedTimestampMillis;%0A            lastLoggedTimestampMillis = time;%0A            log.add(time + %22 (%22 + delta + %22)
  %22 + message
@@ -1558,22 +1558,26 @@
       lo
-g.add(
+ng time = 
 System.c
@@ -1594,20 +1594,206 @@
 Millis()
- + %22
+;%0A            long delta = lastLoggedTimestampMillis == -1 ? 0L : time - lastLoggedTimestampMillis;%0A            lastLoggedTimestampMillis = time;%0A            log.add(time + %22 (%22 + delta + %22)
  %22 + Mes

Update solution logging to include deltas in millis between logged