示例#1
0
    // Constructor
    public LogMessage(string log, string tag, SMLogType type, string stack)
    {
        this.log = log;
        this.tag = tag;
        this.type = type;
        this.stamp = DateTime.Now;
        this.messageID = ++IDCounter;

        string[] stackTraces = stack.Split('\n');
        int len = stackTraces.Length;
        stackTrace = new StackTraceEntry[len];

        int toAssign = 0;
        foreach (string trace in stackTraces)
        {
        if (trace.Contains("SMConsole.Log") || trace.Contains("get_StackTrace()"))
            continue;
        StackTraceEntry entry =new StackTraceEntry(trace, toAssign + 1);
        if(!entry.isEmpty())
        {
            stackTrace[toAssign] = entry;
            toAssign++;
        }
        }

        if(toAssign < len) // copy into smaller array
        {
        StackTraceEntry[] arr = new StackTraceEntry[toAssign];
        for(int i = 0; i < toAssign;i ++)
        {
            arr [i] = stackTrace[i];
        }
        stackTrace = arr;
        }
    }
示例#2
0
  private static void Log(string log, string tag, SMLogType type, string stackTrace)
  {
#if UNITY_EDITOR
    LogMessage message;
    SMConsoleData _data = SMConsoleData.Instance;

    if (stackTrace == StackTraceEntry.EMPTY_STACK_TRACE)
      message = new LogMessage(log, tag, type,Environment.StackTrace);
    else
      message = new LogMessage(log, tag, type, stackTrace);

    _data.logs.Add(message);

    _data.logCounter[(int)type]++;

    string hashKey = message.hashKey();

    if (!_data.collapsedHash.ContainsKey(hashKey))
    {
      CollapsedMessage collapsed = new CollapsedMessage(message);
      _data.collapsedHash.Add(hashKey, collapsed);
    }
    else
    {
      CollapsedMessage collapsed = _data.collapsedHash[hashKey];
      collapsed.counter++;
      _data.collapsedHash[hashKey] = collapsed;
    }

    if (!_data.tags.Contains(message.tag))
    {
      _data.tags.Add(message.tag);
      _data.selectedTags.Add(message.tag);
    }

    // See if should be added to currently showing
     if (_data.searchFilter == SMConsoleData.DEFAULT_SEARCH_STR || _data.searchFilter == "")
    {
      _data.showingLogs.Add(message);
    }
    else
    {
       if(!_data.canCollapse)
       {
         if(message.log.IndexOf(_data.searchFilter, StringComparison.OrdinalIgnoreCase) >= 0)
            _data.showingLogs.Add(message);
       }
       else if(_data.collapsedHash[hashKey].counter == 1) // first instance
       {
         if (message.log.IndexOf(_data.searchFilter, StringComparison.OrdinalIgnoreCase) >= 0)
           _data.showingLogs.Add(_data.collapsedHash[hashKey]);
       }
    }
        if(_data.mainEditorConsole != null)
        {
            _data.mainEditorConsole.Repaint();
        }

#endif
  }
示例#3
0
 public static void Log(string log, string tag, SMLogType type)
 {
     Log(log, tag, type, StackTraceEntry.EMPTY_STACK_TRACE);
 }
示例#4
0
    // returns true if the type (normal, warning , error) is available to display
    bool isMessageTypeAvailable(SMLogType type)
    {
        bool isAvailable = false;

        switch (type)
        {
          case SMLogType.NORMAL:
        isAvailable = _data.showLogs;
        break;
          case SMLogType.WARNING:
        isAvailable = _data.showWarnings;
        break;

          case SMLogType.ERROR:
        isAvailable = _data.showErrors;
        break;
        }
        return isAvailable;
    }
示例#5
0
    // Draws icon of message type
    bool drawIconLabel(SMLogType type, GUISkin skin)
    {
        Texture2D texture = _logTex;

        switch (type)
        {
          case SMLogType.NORMAL:
        texture = _logTex;
        break;

          case SMLogType.WARNING:
        texture = _warningTex;
        break;

          case SMLogType.ERROR:
        texture = _errorTex;
        break;

        }
        //  texture.texelSize = new Vector2(0.2f, 0.2f);

        _logSkin.button.normal.background = texture;
        _logSkin.button.active.background = texture;
        _logSkin.button.focused.background = texture;
        _logSkin.button.hover.background = texture;
        _logSkin.button.onNormal.background = texture;
        _logSkin.button.onActive.background = texture;
        _logSkin.button.onFocused.background = texture;
        _logSkin.button.onHover.background = texture;
        return GUILayout.Button("", _logSkin.button, GUILayout.Height(texture.height), GUILayout.Width(texture.width));
    }