Coloured debug messages

Hi,

If I use System.Diagnostics.Debugger.Log method to log messages, they appear in BLUE in my output window in Xamarin Studio. However, these messages do not appear on the Console in XCode when debugging my device.
If I use System.Diagnostics.Debug then they appear in black, in XCode on my device if I run in Debug mode; not release mode.
If I use Console.WriteLine they do appear in all states on both output window and XCode Console log.

Question: is there a way to give debug messages a COLOR in Xamarin Studio AND output on the console in Xcode on the device?

Posts

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Debugger.Log sends the messages directly to the debugger, not to stdout/stderr.

    I suggest Console.Error.WriteLine - which writes to stderr, and will be shown in red.

  • GregoryMeyersGregoryMeyers USUniversity

    Hey @mhutch‌ Console.Error.WriteLine doesn't produce error messages in Red color, I am using Xamarin Studio in Mac. It is really hard to use Application Output without search functionality or colored output.

  • mhutchmhutch USMember, Xamarin Team Xamurai

    @GregoryMeyers what kind of app are you debugging?

  • GregoryMeyersGregoryMeyers USUniversity

    It is an iOS app, trying to debug some multi threading code, it would be nice if I can search or highlight my logs like we can do with output window.

  • mhutchmhutch USMember, Xamarin Team Xamurai

    If it's on device, then this is a limitation of tunnelling the output back from the device, stdout and stderr are combined into one channel. It should work on simulator though.

  • SenthilRSenthilR USMember

    @mhutch‌ What about searching the output window or streaming the log to some file so I can use editors to search?

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Yes, that would be useful, please file it on UserVoice.

  • shawnlshawnl USMember

    This doesn't seem to color the output even using the simulator.

  • @mhutch, it seems I'm falling in to the same boat as shawnl and GregoryMeyers. Do you have an answer to Console.Error.WriteLine not producing console messages colored red in Xamarin while using iOS simulator?

  • NealCulinerNealCuliner USBeta ✭✭✭

    @mhutch I remember your Evolve talk discussing different color outputs to the application output but I am unable to do this in 5.10.x - is it still available? I also don't see a way of setting Foreground color as in https://developer.xamarin.com/api/type/System.Console/

    I want to ensure exceptions are in red to make them stand out more in a busy application output pane.

    Thanks

  • mhutchmhutch USMember, Xamarin Team Xamurai

    @NealCuliner

    Setting the foreground/background color and other terminal state only works when you're connected to an actual terminal. The XS Application Output is just a text output.

    The Application Output does colorize different kinds of message:

    1. stdout (Console.Out) is black
    2. stderr (Console.Error) is red
    3. debugger (Debug..WriteLine) output is blue
    4. debugger log messages are grey

    I just checked with a console app in 5.10 and this does still work.

    However, there are limitations. #3 and #4 only work when debugging, and #2 doesn't work on devices at the moment.

  • NealCulinerNealCuliner USBeta ✭✭✭

    Thanks @mhutch but I must be doing something wrong, see attached.

    image

  • NealCulinerNealCuliner USBeta ✭✭✭

    Okay, maybe this doesn't work on iPhone Simulator either?

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Yes, sorry, you're right. I did some research and it looks like there are several issues breaking this right now. I filed bugs.

  • yvrezyvrez BEMember ✭✭

    Still not working in Xamarin Studio 6.1.2 (Beta)

Sign In or Register to comment.