Search Unity

Debug.LogFormat formatting bug....right?

Discussion in 'Scripting' started by jobemakar_unity, Feb 15, 2018.

  1. jobemakar_unity

    jobemakar_unity

    Joined:
    Feb 13, 2018
    Posts:
    5
    Instead of just using Debug.Log, Debug.Warn, etc, I am using their formatting counterparts to get color coding in the console. So Debug.LogFormat, Debug.WarnFormat, etc.

    Using RTF tags you can format the message to be colored. This works, unless you have 2 or more new lines in the log.

    This works:
    Code (CSharp):
    1. Debug.LogFormat("Message: <color=blue>{0}</color>", "one \n two three");
    This fails (only difference from the above is the additional \n):
    Code (CSharp):
    1. Debug.LogFormat("Message: <color=blue>{0}</color>", "one \n two \n three");
    The one that fails still prints in the console. But it prints it as you see it above, tag and all.

    I'd consider this a bug because I see no documentation indicating that this is a bad format.

    Let me know if there is something I'm missing here.

    Jobe
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536
    Click the message, it's truncated and only seen in the full log.
     
  3. jobemakar_unity

    jobemakar_unity

    Joined:
    Feb 13, 2018
    Posts:
    5
    Interesting, thanks. I wouldn't have thought that the # of lines / log visible in the console would matter. IMO the best use case for the color formatting is viewing in the list in the console, rather than formatting elements within a single log visible in the pane below it after the log is clicked. But thanks, with this knowledge i should able to format my logs in two chunks so that it is colored in both places (until someone adjusts the # of visible lines).
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
  5. jobemakar_unity

    jobemakar_unity

    Joined:
    Feb 13, 2018
    Posts:
    5
    I wasn't suggesting showing a huge log in the console. I was suggesting that the console respects the formatting that you applied. It only respects the formatting that it can *see* in the 2 lines visible, until clicked on.