/* * This file is part of LanternServer, licensed under the MIT License (MIT). * * Copyright (c) LanternPowered <https://www.lanternpowered.org> * Copyright (c) SpongePowered <https://www.spongepowered.org> * Copyright (c) contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the Software), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.lanternpowered.server.console.launch; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; import java.io.IOException; import java.io.PrintStream; import java.util.Locale; final class LoggingPrintStream extends PrintStream { private final LoggingOutputStream out; LoggingPrintStream(Logger logger, Level level) { this(new LoggingOutputStream(logger, level)); } private LoggingPrintStream(LoggingOutputStream out) { super(out, true); this.out = out; } @Override public void write(byte[] buf, int off, int len) { this.out.flush = false; super.write(buf, off, len); this.out.flush = true; } @Override public PrintStream append(char c) { return super.append(c); } @Override public PrintStream append(CharSequence csq) { return super.append(csq); } @Override public PrintStream append(CharSequence csq, int start, int end) { return super.append(csq, start, end); } @Override public void write(byte[] b) throws IOException { super.write(b); } @Override public void write(int b) { super.write(b); } @Override public void print(boolean b) { super.print(b); } @Override public void print(char c) { super.print(c); } @Override public void print(int i) { super.print(i); } @Override public void print(long l) { super.print(l); } @Override public void print(float f) { super.print(f); } @Override public void print(double d) { super.print(d); } @Override public void print(char[] s) { super.print(s); } @Override public void print(String s) { super.print(s); } @Override public void print(Object obj) { super.print(obj); } @Override public void println() { super.println(); } @Override public void println(boolean x) { super.println(x); } @Override public void println(char x) { super.println(x); } @Override public void println(int x) { super.println(x); } @Override public void println(long x) { super.println(x); } @Override public void println(float x) { super.println(x); } @Override public void println(double x) { super.println(x); } @Override public void println(char[] x) { super.println(x); } @Override public void println(String x) { super.println(x); } @Override public void println(Object x) { super.println(x); } @Override public PrintStream printf(String format, Object... args) { return super.printf(format, args); } @Override public PrintStream printf(Locale l, String format, Object... args) { return super.printf(l, format, args); } @Override public PrintStream format(String format, Object... args) { return super.format(format, args); } @Override public PrintStream format(Locale l, String format, Object... args) { return super.format(l, format, args); } @Override public boolean checkError() { return super.checkError(); } @Override public void flush() { super.flush(); } @Override public void close() { super.close(); } }