コード例 #1
0
    /// <summary>
    /// Converts a given log element into a piece of gui content to be displayed
    /// </summary>
    GUIContent GetLogLineGUIContent(UberLogger.LogInfo log, bool showTimes, bool showChannels)
    {
        var showMessage = log.Message;

        //Make all messages single line
        showMessage = showMessage.Replace(UberLogger.Logger.UnityInternalNewLine, " ");

        // Format the message as follows:
        //     [channel] 0.000 : message  <-- Both channel and time shown
        //     0.000 : message            <-- Time shown, channel hidden
        //     [channel] : message        <-- Channel shown, time hidden
        //     message                    <-- Both channel and time hidden
        var showChannel            = showChannels && !string.IsNullOrEmpty(log.Channel);
        var channelMessage         = showChannel ? string.Format("[{0}]", log.Channel) : "";
        var channelTimeSeparator   = (showChannel && showTimes) ? " " : "";
        var timeMessage            = showTimes ? string.Format("{0}", log.GetRelativeTimeStampAsString()) : "";
        var prefixMessageSeparator = (showChannel || showTimes) ? " : " : "";

        showMessage = string.Format("{0}{1}{2}{3}{4}",
                                    channelMessage,
                                    channelTimeSeparator,
                                    timeMessage,
                                    prefixMessageSeparator,
                                    showMessage
                                    );

        var content = new GUIContent(showMessage);

        return(content);
    }
コード例 #2
0
    /// <summary>
    /// Converts the entire message log to a multiline string
    /// </summary>
    public string ExtractLogListToString()
    {
        string result = "";

        foreach (CountedLog log in RenderLogs)
        {
            UberLogger.LogInfo logInfo = log.Log;
            result += logInfo.GetRelativeTimeStampAsString() + ": " + logInfo.Severity + ": " + logInfo.Message + "\n";
        }
        return(result);
    }
コード例 #3
0
    /// <summary>
    /// Converts a given log element into a piece of gui content to be displayed
    /// </summary>
    GUIContent GetLogLineGUIContent(UberLogger.LogInfo log, bool showTimes)
    {
        var showMessage = log.Message;

        //Make all messages single line
        showMessage = showMessage.Replace(UberLogger.Logger.UnityInternalNewLine, " ");
        if (showTimes)
        {
            showMessage = log.GetRelativeTimeStampAsString() + ": " + showMessage;
        }

        var content = new GUIContent(showMessage, GetIconForLog(log));

        return(content);
    }