@@ -0,0 +1,3154 @@
+/*%0A * This file is part of sprintj, licensed under the MIT License (MIT).%0A *%0A * Copyright (c) 2014 Oliver Stanley %3Chttp://ollie.pw%3E%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy%0A * of this software and associated documentation files (the %22Software%22), to deal%0A * in the Software without restriction, including without limitation the rights%0A * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A * copies of the Software, and to permit persons to whom the Software is%0A * furnished to do so, subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in%0A * all copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN%0A * THE SOFTWARE.%0A */%0Apackage pw.ollie.sprint.log;%0A%0Aimport pw.ollie.sprint.format.StringFormatter;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0Aimport java.util.List;%0Aimport java.util.logging.Handler;%0Aimport java.util.logging.LogRecord;%0A%0A/**%0A * A logging %7B@link Handler%7D which applies one or more %7B@link StringFormatter%7Ds'%0A * %7B@link StringFormatter#format(String)%7D method to the output of the logger.%0A */%0Apublic class StringFormattingHandler extends Handler %7B%0A    /**%0A     * The %7B@link List%7D of %7B@link StringFormatter%7Ds being applied to the output.%0A     */%0A    private List%3CStringFormatter%3E formatters;%0A    /**%0A     * Whether the %7B@link StringFormattingHandler%7D is currently active.%0A     */%0A    private boolean active = true;%0A%0A    public StringFormattingHandler() %7B%0A        this.formatters = new ArrayList%3C%3E();%0A    %7D%0A%0A    public StringFormattingHandler(Collection%3CStringFormatter%3E formatters) %7B%0A        this.formatters = new ArrayList%3C%3E(formatters);%0A    %7D%0A%0A    public StringFormattingHandler(StringFormatter... formatters) %7B%0A        this.formatters = Arrays.asList(formatters);%0A    %7D%0A%0A    @Override%0A    public void publish(LogRecord record) %7B%0A        if (formatters == null %7C%7C formatters.isEmpty()) %7B%0A            return;%0A        %7D%0A%0A        formatters.forEach((formatter) -%3E%0A                record.setMessage(formatter.format(record.getMessage())));%0A    %7D%0A%0A    public boolean isActive() %7B%0A        return active;%0A    %7D%0A%0A    public StringFormattingHandler setActive(boolean active) %7B%0A        this.active = active;%0A        return this;%0A    %7D%0A%0A    public StringFormattingHandler add(StringFormatter formatter) %7B%0A        formatters.add(formatter);%0A        return this;%0A    %7D%0A%0A    public StringFormattingHandler remove(StringFormatter formatter) %7B%0A        formatters.remove(formatter);%0A        return this;%0A    %7D%0A%0A    @Override%0A    public void flush() %7B%0A    %7D%0A%0A    @Override%0A    public void close() throws SecurityException %7B%0A    %7D%0A%7D%0A

Add StringFormattingHandler for logging