package com.ttaylorr.dev.logger;

import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SimpleLogger implements Logger {

    private final PrintStream out;
    private final SimpleDateFormat dateFormat;

    public SimpleLogger(PrintStream stream) {
        this.out = stream;
        this.dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    }

    @Override
    public void debug(String str, Object... args) {
        this.log(LogLevel.DEBUG, str, args);
    }

    @Override
    public void info(String str, Object... args) {
        this.log(LogLevel.INFO, str, args);
    }

    @Override
    public void warn(String str, Object... args) {
        this.log(LogLevel.WARN, str, args);
    }

    @Override
    public void severe(String str, Object... args) {
        this.log(LogLevel.SEVERE, str, args);
    }

    @Override
    public void debug(String str) {
        this.debug(str, null);
    }

    @Override
    public void info(String str) {
        this.info(str, null);
    }

    @Override
    public void warn(String str) {
        this.warn(str, null);
    }

    @Override
    public void severe(String str) {
        this.severe(str, null);
    }

    @Override
    public void log(LogLevel level, String str, Object... args) {
        StringBuilder builder = new StringBuilder();

        builder.append(formatDate()).append(' ');
        builder.append('[').append(level.name()).append(']').append(' ');

        int argCount = 0;

        for(String s : str.split("\\s")) {
            if (s.equals("{}")) {
                builder.append(args[++argCount]);
            } else {
                builder.append(s);
            }
        }

        this.out.println(builder.toString());
    }

    public String formatDate() {
        return this.dateFormat.format(new Date());
    }
}

@@ -112,16 +112,80 @@
 il.Date;
+%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;
 %0A%0Apublic
@@ -1577,207 +1577,261 @@
     
-for(String s : str.split(%22%5C%5Cs%22)) %7B%0A            if (s.equals(%22%7B%7D%22)) %7B%0A                builder.append(args%5B++argCount%5D);%0A            %7D else %7B%0A                builder.append(s);%0A            %7D%0A        %7D%0A
+Pattern pattern = Pattern.compile(Pattern.quote(%22%7B%7D%22));%0A        Matcher matcher = pattern.matcher(str);%0A%0A        while (matcher.find()) %7B%0A            str.replaceFirst(matcher.group(), args%5B++argCount%5D.toString());%0A        %7D%0A%0A        builder.append(str);
 %0A   

Rewrite arg insertion to be not dumb