TerminalConsoleAppender icon indicating copy to clipboard operation
TerminalConsoleAppender copied to clipboard

Colors not working

Open BlueTree242 opened this issue 3 years ago • 22 comments

Hi, i am trying to use that library on my standalone project. However Minecraft Formatting (i know it is deprecated, but i want to use it) is not working as expected

  1. Not working in intellij, while log4j's highlight colors are working perfectly, and it works if i use the override property
  2. I am getting a weird character in the place of the color code, even if colors aren't even applied: image

Am i doing something incorrectly?

BlueTree242 avatar Aug 28 '22 13:08 BlueTree242

Am i doing something incorrectly?

I don't know, you didn't post any of your configuration or code so I could just make bad guesses. :/

stephan-gh avatar Aug 28 '22 14:08 stephan-gh

https://github.com/BlueTree242/PreBot/blob/f8f23fd9e2aa9277abbee87b788c2b85fa16ae35/launcher/src/main/resources/log4j2.xml this is my log4j2.xml

BlueTree242 avatar Aug 28 '22 14:08 BlueTree242

So does it only not work in IntelliJ?

stephan-gh avatar Aug 28 '22 15:08 stephan-gh

it works in windows terminal, and in intellij if i use override property, and im getting that weird character in both cases

BlueTree242 avatar Aug 28 '22 15:08 BlueTree242

For the IntelliJ detection: It's complicated to get it right, I think the detection might not work correctly at the moment if you run using the Gradle task in IntelliJ. (It should work when using the normal IntelliJ run configurations.)

That char looks like you put more than §c in the string. I'd say the color (§c?) is applied correctly but there is some garbage before it.

stephan-gh avatar Aug 28 '22 16:08 stephan-gh

yup, i wanna remove the garbage

BlueTree242 avatar Aug 28 '22 16:08 BlueTree242

For the IntelliJ detection: It's complicated to get it right, I think the detection might not work correctly at the moment if you run using the Gradle task in IntelliJ. (It should work when using the normal IntelliJ run configurations.)

That char looks like you put more than §c in the string. I'd say the color (§c?) is applied correctly but there is some garbage before it.

Well i only put a color code, even if i did multiple... It shouldn't act like that right?

BlueTree242 avatar Aug 28 '22 19:08 BlueTree242

If you'd do e.g. §§c it would likely produce something like this, since the converter only touches valid color codes.

stephan-gh avatar Aug 28 '22 21:08 stephan-gh

(Although maybe one would expect the terminal to display § and not this garbage...)

stephan-gh avatar Aug 28 '22 21:08 stephan-gh

im sure i didn't do that, ive wrote the color code 5 separate times i never saw extra §

BlueTree242 avatar Aug 28 '22 21:08 BlueTree242

Uh, the garbage is always only at the beginning of the line?

stephan-gh avatar Aug 28 '22 21:08 stephan-gh

no, i tried putting the color code in middle and the garbage was in middle too

BlueTree242 avatar Aug 28 '22 21:08 BlueTree242

I'd suggest removing the {strip} from the %minecraftFormatting in the RollingRandomAccessFile output, and then look at the log file with a proper editor to find out what kind of char this really is (the "?" doesn't tell much).

stephan-gh avatar Aug 28 '22 21:08 stephan-gh

good idea, ill try

BlueTree242 avatar Aug 28 '22 21:08 BlueTree242

image i see this when i open logs in intellij

BlueTree242 avatar Aug 28 '22 21:08 BlueTree242

Open it in a different editor? Perhaps even in a hex editor if necessary.

stephan-gh avatar Aug 29 '22 17:08 stephan-gh

i tried visual studio code, and i got the same thing, i tried notepad and i got this: image i don't have any more editors, do you suggest any others

BlueTree242 avatar Aug 29 '22 18:08 BlueTree242

Looks like there is a Hex Editor extension for vscode that would allow you to see the numeric value of that char: https://marketplace.visualstudio.com/items?itemName=ms-vscode.hexeditor (no idea how to use it)

stephan-gh avatar Aug 29 '22 20:08 stephan-gh

ok. using hex editor, i got 3 dots in location of garbage, this is when clicking each in order: image image image

BlueTree242 avatar Aug 30 '22 08:08 BlueTree242

OK very strange, not sure where that'd come from. If you want you can upload your current code and I can take a brief look if I see something. (Can't seem to find the colored message in the repo you linked.)

stephan-gh avatar Aug 31 '22 18:08 stephan-gh

i cannot use color codes in the repo if it's not working, if you want to reproduce locally, clone the repo, add a color code here, and run the main class here, if you want to try windows terminal build it and run the prebot jar in launcher/build/libs

BlueTree242 avatar Aug 31 '22 19:08 BlueTree242

if required i can make a test branch for you

BlueTree242 avatar Aug 31 '22 19:08 BlueTree242

i noticed a very important thing, i noticed that the compiled string contained the garbage, which means that this library might be innocent not causing any trouble

BlueTree242 avatar Sep 01 '22 13:09 BlueTree242

Yup, that was the problem. for anyone having this problem set your encoding in gradle to utf8 in all project (if multi module). Thanks for helping

BlueTree242 avatar Sep 01 '22 13:09 BlueTree242