2

In the output of a script that calls Mathematica I would like to be able to differentiate lines printed by mathematica from lines printed by something else. I thought of prefacing lines printed by Mathematica with for example "m:". Is this possible?

Kvothe
  • 4,419
  • 9
  • 28

1 Answers1

1

As suggested by Szabolcs, I used the Villegas-Gayley method

Unprotect[Print];

Print[args___]:=Block[{$inMsg=True}, Print["|m:>",args,"<:m|"] ]/;!TrueQ[$inMsg]

Protect[Print];

This works well. Ideally I could do the same also for warning messages but I haven't quite figured out yet what the appropriate change would be to Message.

Kvothe
  • 4,419
  • 9
  • 28