Dmitry Golubets
Dmitry Golubets

Reputation: 570

SBT console encoding for test results

I have an SBT + Scalatest project. Now my tests log in console something like this:

[info] - should do something *** FAILED *** 
[info] java.lang.Exception: ╧ЁштхЄ!

That's not very useful of cause.. Exception text is in Cyrillic so I have to set cp866 charset on console stream to display it correctly.

I've tried

Console.setOut(new PrintStream(System.out, true, "cp866"))

But SBT ignores it. It seems that SBT constructs it's own stream for logging various messages, but I can't find where and how to alter it..

There is a way to add custom logger, but it's an overkill.

Upvotes: 1

Views: 331

Answers (1)

Dmitry Golubets
Dmitry Golubets

Reputation: 570

I've found a solution. I can create a custom LogManager

val customLogManager = LogManager.defaultManager(ConsoleOut.printStreamOut(new java.io.PrintStream(System.out, true, "cp866")))

And set it in project settings:

logManager := customLogManager

Though, I'm not sure if it is the best solution. One flaw is that you have to provide logManager setting for every project. Inheriting it from build settings doesn't work for some reason.

Upvotes: 1

Related Questions