Hello Im not sure if this is my fault, or a actual...
# announcements
l
Hello Im not sure if this is my fault, or a actual bug in the Kotlin Compiler. In the main function, the first thing i am doing is replacing the System.out with a own class(Java). Afterwards i am only invoking thoose methods:
Copy code
fun main(args: Array<String>) {

    System.setOut(SprummlbotOutStream())

    System.out.println("Test System.out.println()")
    println("Test println")
    

}
Thats the output:
Copy code
[12.3.2018 00:26:40 | INFO] Test System.out.println()
Test println

Process finished with exit code 0
SprummlbotOutStream
Copy code
public class SprummlbotOutStream extends PrintStream {

    public SprummlbotOutStream() {
        super(System.out);
    }

    @Override
    public void println(String msg) {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("d.M.Y HH:mm:ss");
        if (!msg.startsWith("["))
            msg = " " + msg;
        super.println("[" + sdf.format(cal.getTime()) + " | INFO]" + msg);
    }
}
My question: why does println use the old stream? Kotlin pl: 1.2.30 JDK: 1.8.0_162
i
println
uses the current stream, it's just that stream does not override
println(Object msg)
method overload.
l
ohhh
thx
i
Yeah,
PrintStream
doesn't seem to be well suited for overriding. Actually you need to override each
print*
method, if you want to process/modify the message.