1
$\begingroup$

When I run large computation with 1,000's of iterations, then later look at the console looking for any errors or warnings generated, it is hard to locate them scrolling up and down, as the color of the messages by default is gray, which is close to the black color used for normal print output.

Is there a way to change the color so they are red?

There was a similar question here changing-color-of-error-messages but looking at it, it is for messages going to the notebook itself, not the console. And it requires changing the whole notebook default style as I understood the answer, which I do not think will have any effect as my messages go to the console?

I actually also tried to do what the above answer says which is to Then add those style cells: but I had no idea how do that. How does one add new cell styles to a notebook? I looked at option at top of the notebook and see no option to add a cell style?

Here is a typical screen shot of the console showing what I mean

enter image description here

With 10's of thousands of lines, it is easier to spot these if they were in red while scrolling looking for the message when I hear a beep.

I have the following at the top of my notebook before starting the computation

CurrentValue[$FrontEnd, {"PrintAction"}] = {"PrintToConsole"}
CurrentValue[$FrontEnd, {"MessageOptions", 
   "KernelMessageAction"}] = {"PrintToConsole", "Beep"}

This causes everything (including normal Print) to go to console so I do not clutter the notebook.

I just need the color of any error or warning in the console to be red so easy to see. Any option in options inspector to do this easily?

V 13.0.1 on windows.

$\endgroup$
2
  • $\begingroup$ $MessagePrePrint = Style[#, Red, 18, Bold] &; ? Also take a look at $SyntaxHandler. $\endgroup$
    – Syed
    May 26, 2022 at 8:20
  • $\begingroup$ @Syed thanks for the suggestion. But this did not do exactly what I wanted. I did $MessagePrePrint = Style[#, Red, 18, Bold] &; then DSolve[y'[x] == 1, y, z] the error message on console still printed in gray by DSolve Also when I did 1/0 it showed only the 1/0 in red, but the rest of the message still in gray. Screen shot !Mathematica graphics $\endgroup$
    – Nasser
    May 26, 2022 at 8:37

1 Answer 1

4
$\begingroup$

The style of a message is controlled by the setting for "MessageText". You can modify the stylesheet for the messages notebook with:

SetOptions[
    MessagesNotebook[],
    StyleDefinitions -> Notebook[
        {
        Cell[StyleData[StyleDefinitions->"Default.nb"]],
        Cell[StyleData["MessageText"], FontColor->RGBColor[1, 0, 0]]
        },
        StyleDefinitions->"PrivateStylesheetFormatting.nb"
    ]
]

Then, messages should be printed in red.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.