Ejemplo n.º 1
0
        void OnLog(string condition, string stackTrace, UnityEngine.LogType type)
        {
            if (!canShow)
            {
                if (MessageList.Count > 100)
                {
                    MessageList.Clear();
                }
            }
            sLogData mess = new sLogData();

            mess.message    = condition;
            mess.stackTrace = stackTrace;
            mess.type       = (eLogType)(int)type;
            if (type == UnityEngine.LogType.Error || type == UnityEngine.LogType.Assert || type == UnityEngine.LogType.Exception)
            {
                mess.color = Color.red;
            }
            else if (type == UnityEngine.LogType.Log)
            {
                mess.color = Color.white;
            }
            else if (type == UnityEngine.LogType.Warning)
            {
                mess.color = Color.yellow;
            }
            MessageList.Add(mess);
        }
Ejemplo n.º 2
0
        void OnReceiveLogMsg(string condition, string stackTrace, UnityEngine.LogType type)
        {
            switch (type)
            {
            case UnityEngine.LogType.Log:
                Info(condition);
                break;

            case UnityEngine.LogType.Error:
                Error(condition, stackTrace);
                break;

            case UnityEngine.LogType.Assert:
                Fatal(condition, stackTrace);
                break;

            case UnityEngine.LogType.Warning:
                Warning(condition, stackTrace);
                break;

            case UnityEngine.LogType.Exception:
                Fatal(condition, stackTrace);
                break;

            default:
                Info(condition);
                break;
            }
        }
        public static Oxide.Core.Logging.LogType ToLogType(this UnityEngine.LogType logType)
        {
            switch (logType)
            {
            case UnityEngine.LogType.Error:
            case UnityEngine.LogType.Assert:
            case UnityEngine.LogType.Exception:
            {
                return(1);
            }

            case UnityEngine.LogType.Warning:
            {
                return(3);
            }

            case UnityEngine.LogType.Log:
            {
                return(2);
            }

            default:
            {
                return(2);
            }
            }
        }
Ejemplo n.º 4
0
        internal static void UnityLog(string message, string trace, UnityEngine.LogType type)
        {
            if (string.IsNullOrWhiteSpace(message) || message.MatchesAny(TO_IGNORE))
            {
                return;
            }

            if (type == UnityEngine.LogType.Exception)
            {
                HandleException(new GuuUnmanagedException(message, trace), UNITY_LOGGER);
                return;
            }

            string toDisplay = message;

            if (!string.IsNullOrWhiteSpace(trace))
            {
                toDisplay += "\n" + trace;
            }

            if (type == UnityEngine.LogType.Error)
            {
                toDisplay += GuuCore.GUU_DEBUG ? "\n-- FULL TRACE --\n" + new StackTrace() : string.Empty;
            }

            UNITY_LOGGER?.Log(!message.Contains("WarningException") ? ModLogger.UNITY_TO_GUU[type] : ModLogger.UNITY_TO_GUU[UnityEngine.LogType.Warning],
                              Regex.Replace(toDisplay, @"\[INFO]\s|\[ERROR]\s|\[WARNING]\s", ""));
        }
Ejemplo n.º 5
0
    private static void onLogMessageReceived(string condition, string stackTrace, UnityEngine.LogType type)
    {
        switch (type)
        {
        case LogType.Error:
            log.ErrorFormat("{0}\r\n{1}", condition, stackTrace.Replace("\n", "\r\n"));
            break;

        case LogType.Assert:
            log.DebugFormat("{0}\r\n{1}", condition, stackTrace.Replace("\n", "\r\n"));
            break;

        case LogType.Exception:
            log.FatalFormat("{0\r\n{1}", condition, stackTrace.Replace("\n", "\r\n"));
            break;

        case LogType.Warning:
            log.WarnFormat("{0}\r\n{1}", condition, stackTrace.Replace("\n", "\r\n"));
            break;

        default:
            log.Info(condition);
            break;
        }
    }
Ejemplo n.º 6
0
 private static void OnMessage(string message, string stacktrace, UnityEngine.LogType type)
 {
     if (RCon.isInput || RCon.listenerNew == null)
     {
         return;
     }
     RCon.Response response = new RCon.Response();
     response.Identifier = RCon.responseIdentifier;
     response.Message    = message;
     response.Stacktrace = stacktrace;
     response.Type       = RCon.LogType.Generic;
     if (type == null || type == 4)
     {
         response.Type = RCon.LogType.Error;
     }
     if (type == 1 || type == 2)
     {
         response.Type = RCon.LogType.Warning;
     }
     if (string.IsNullOrEmpty(RCon.responseConnection))
     {
         RCon.listenerNew.BroadcastMessage(JsonConvert.SerializeObject((object)response, (Formatting)1));
     }
     else
     {
         RCon.listenerNew.SendMessage(RCon.responseConnection, JsonConvert.SerializeObject((object)response, (Formatting)1));
     }
 }
 private static void HandleLog(string message, string stackTrace, UnityEngine.LogType logType)
 {
     if (!String.IsNullOrEmpty(message) && !RustExtension.Filter.Any <string>(new Func <string, bool>(message.Contains)))
     {
         Interface.Oxide.RootLogger.HandleMessage(message, stackTrace, logType.ToLogType());
     }
 }
Ejemplo n.º 8
0
 private static void OnMessage(string message, string stacktrace, UnityEngine.LogType type)
 {
     if (!isInput && listenerNew != null)
     {
         Response response = default(Response);
         response.Identifier = responseIdentifier;
         response.Message    = message;
         response.Stacktrace = stacktrace;
         response.Type       = LogType.Generic;
         if (type == UnityEngine.LogType.Error || type == UnityEngine.LogType.Exception)
         {
             response.Type = LogType.Error;
         }
         if (type == UnityEngine.LogType.Assert || type == UnityEngine.LogType.Warning)
         {
             response.Type = LogType.Warning;
         }
         if (responseConnection < 0)
         {
             listenerNew.BroadcastMessage(JsonConvert.SerializeObject(response, Formatting.Indented));
         }
         else
         {
             listenerNew.SendMessage(responseConnection, JsonConvert.SerializeObject(response, Formatting.Indented));
         }
     }
 }
Ejemplo n.º 9
0
    static void SaveToFile(string prefix, string content, string callstack, UnityEngine.LogType _type)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append("[");
        sb.Append(prefix);
        sb.Append("] ");
        sb.Append(string.Format("[{0}] ", System.DateTime.Now));
        sb.AppendLine(content);

        if (sStackLogTypeList.ContainsKey(_type))
        {
            sb.AppendLine("*******************堆栈*******************");
            if (callstack.Length > 2)
            {
                sb.AppendLine(callstack);
            }
            else
            {
                sb.AppendLine(GetStackTrace());
            }
            sb.AppendLine("******************************************");
        }

        System.IO.File.AppendAllText(GetNowLogName(), sb.ToString(), System.Text.Encoding.UTF8);
    }
Ejemplo n.º 10
0
 private void _OnLogMessageReceived(string condition, string stackTrace, UnityEngine.LogType type)
 {
     if (UnityEngine.LogType.Exception == type)
     {
         // TODO: Collection log info and send to remote server???
     }
 }
Ejemplo n.º 11
0
    void handleUnityLog(string condition, string stackTrace, UnityEngine.LogType unityLogType)
    {
        LogType logType = LogType.info;

        switch (unityLogType)
        {
        case UnityEngine.LogType.Error:
            logType = LogType.error;
            break;

        case UnityEngine.LogType.Assert:
            logType = LogType.exception;
            break;

        case UnityEngine.LogType.Warning:
            if (logs.Find(log => log.msg == condition) != null)
            {
                return;
            }
            logType = LogType.warning;
            break;

        case UnityEngine.LogType.Log:
            logType = LogType.info;
            break;

        case UnityEngine.LogType.Exception:
            logType = LogType.exception;
            break;
        }
        addLog(new Log(logType, null, "Unity", condition, new List <string> ()
        {
            stackTrace
        }));
    }
Ejemplo n.º 12
0
 private static void LogCallback(string condition, string stackTrace, UnityEngine.LogType type)
 {
     foreach (ILogOutputListener linstener in _logOutputListeners)
     {
         linstener.OnLog(condition, stackTrace, type);
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Called whenever the unity system logs a message, but we will only use it for exceptions.
 /// </summary>
 /// <param name="condition">Message.</param>
 /// <param name="stacktrace">Stacktrace.</param>
 /// <param name="logType">Log type.</param>
 private static void ExceptionCallBack(string condition, string stacktrace, UnityEngine.LogType logType)
 {
     if (logType == UnityEngine.LogType.Exception || logType == UnityEngine.LogType.Assert)
     {
         Logger.LogException(condition, stacktrace);
     }
 }
    static bool ILogger_LogFormat__LogType__String__Object_Array(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 3)
        {
            UnityEngine.LogType arg0 = (UnityEngine.LogType)JSApi.getEnum((int)JSApi.GetType.Arg);
            System.String       arg1 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg);
            System.Object[]     arg2 = JSDataExchangeMgr.GetJSArg <System.Object[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new System.Object[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (System.Object)JSMgr.datax.getWhatever((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            ((UnityEngine.ILogger)vc.csObj).LogFormat(arg0, arg1, arg2);
        }

        return(true);
    }
Ejemplo n.º 15
0
 private static void OnMessage(string message, string stacktrace, UnityEngine.LogType type)
 {
     if (RCon.isInput)
     {
         return;
     }
     if (RCon.listenerNew != null)
     {
         RCon.Response response = new RCon.Response()
         {
             Identifier = RCon.responseIdentifier,
             Message    = message,
             Stacktrace = stacktrace,
             Type       = RCon.LogType.Generic
         };
         if (type == UnityEngine.LogType.Error || type == UnityEngine.LogType.Exception)
         {
             response.Type = RCon.LogType.Error;
         }
         if (type == UnityEngine.LogType.Assert || type == UnityEngine.LogType.Warning)
         {
             response.Type = RCon.LogType.Warning;
         }
         if (string.IsNullOrEmpty(RCon.responseConnection))
         {
             RCon.listenerNew.BroadcastMessage(JsonConvert.SerializeObject(response, Formatting.Indented));
             return;
         }
         RCon.listenerNew.SendMessage(RCon.responseConnection, JsonConvert.SerializeObject(response, Formatting.Indented));
     }
 }
Ejemplo n.º 16
0
        private LogType UnityLogTypeToFastLogType(UnityEngine.LogType type)
        {
            LogType ret = default;

            switch (type)
            {
            case UnityEngine.LogType.Error:
            case UnityEngine.LogType.Exception:
            case UnityEngine.LogType.Assert:
            {
                ret = LogType.ERROR;

                break;
            }

            case UnityEngine.LogType.Warning:
            {
                ret = LogType.WARNING;

                break;
            }

            case UnityEngine.LogType.Log:
            {
                ret = LogType.INFO;

                break;
            }
            }

            return(ret);
        }
Ejemplo n.º 17
0
    // 接收参数为unity的logType
    public void SendLog(string content, string category, UnityEngine.LogType logType)
    {
        UtilLogType logMessageType = UtilLogType.COMMON;

        switch (logType)
        {
        case UnityEngine.LogType.Assert:
            logMessageType = UtilLogType.ERROR;
            break;

        case UnityEngine.LogType.Error:
            logMessageType = UtilLogType.ERROR;
            break;

        case UnityEngine.LogType.Exception:
            logMessageType = UtilLogType.EXCEPTION;
            break;

        case UnityEngine.LogType.Log:
            logMessageType = UtilLogType.COMMON;
            break;

        case UnityEngine.LogType.Warning:
            logMessageType = UtilLogType.WARNING;
            break;

        default:
            break;
        }

        SendLog(content, category, logMessageType);
    }
Ejemplo n.º 18
0
 private static void OnUnityLog(string msg, string stackTrace, UnityEngine.LogType type)
 {
     if ((Input.GetKey(KeyCode.L) && Input.GetKey(KeyCode.P)) || PRINT_STACK_TRACE)
     {
         LogInfo("Unity Stack Trace:\n" + msg + "\n" + stackTrace);
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Unity打印数据到控制台,并且退出测试
        /// </summary>
        /// <param name="massage">打印的数据</param>
        /// <param name="logType">报告信息类型</param>
        /// <param name="exitOnFinished">是否结束模拟器(仅仅再编辑器模式下运行)</param>
        public static void LogRExit(object massage, /*[DefaultValue(LogType.Log)]*/ UnityEngine.LogType logType = LogType.Log, bool exitOnFinished = true)
        {
            switch (logType)
            {
            case LogType.Error:
                Debug.LogError(massage);
                break;

            case LogType.Assert:
                Debug.LogAssertion(massage);
                break;

            case LogType.Warning:
                Debug.LogWarning(massage);
                break;

            case LogType.Log:
                Debug.Log(massage);
                break;

            case LogType.Exception:
                Debug.LogException(massage as Exception);
                break;

            default:
                break;
            }
#if UNITY_EDITOR
            if (exitOnFinished)
            {
                UnityEditor.EditorApplication.isPlaying = false;
            }
#endif
        }
Ejemplo n.º 20
0
    /**
     * Get entries from console starting on entry id @a fromId and add it into @a items.
     * @param items List of readed console items.
     * @param fromId Start reading from this id.
     * @return Number of readed entries.
     */
    public int GetEntries(LinkedList <DebugConsoleItem> items, int fromId)
    {
        _startGettingEntriesMethod.Invoke(null, null);

        int cnt       = EntriesCount();
        int readedCnt = 0;

        for (int i = fromId; i < cnt; ++i, ++readedCnt)
        {
            _getEntryInternalParams[0] = i;
            object entry = _getEntryInternalMethod.Invoke(null, _getEntryInternalParams);
            if (entry != null)
            {
                object unityEntry           = _getEntryInternalParams[1];
                string condition            = _conditionField.GetValue(unityEntry) as string;
                int    instanceId           = (int)_instanceIdField.GetValue(unityEntry);
                string fileName             = _fileField.GetValue(unityEntry) as string;
                int    line                 = (int)_lineField.GetValue(unityEntry);
                UnityEngine.LogType logType = LogTypeFromEntryType((int)_modeField.GetValue(unityEntry));
                DebugConsoleItem    item    = new DebugConsoleItem(condition, instanceId, logType, fileName, line);

                items.AddLast(item);
            }
        }

        _endGettingEntriesMethod.Invoke(null, null);

        return(readedCnt);
    }
Ejemplo n.º 21
0
        public static void Init(InputField field, Queue queue)
        {
            m_Queue = queue;
            m_Field = field;
            if (!is_OpenDebug)
            {
                return;
            }
            SendUDP("Unity已连接服务器。");
//         if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor)
//         {
//             RunPythonConsole();
//         }
            m_LogCallback = (condition, stackTrace, type) => {
                // 只打印error
                if (type != UnityEngine.LogType.Error)
                {
                    return;
                }
                SendUDP("#" + (int)type);
                if (m_LastLogType != type)
                {
                    m_LastLogType = type;
                    SendUDP("#" + (int)type);
                }
                SendUDP(condition);
                if (type != UnityEngine.LogType.Log)
                {
//                 SendUDP(stackTrace);
                }
            };
//         UnityEngine.Application.logMessageReceived += m_LogCallback;
        }
Ejemplo n.º 22
0
 public static void AddStackLogType(UnityEngine.LogType _type)
 {
     if (sStackLogTypeList.ContainsKey(_type))
     {
         return;
     }
     sStackLogTypeList.Add(_type, _type.ToString());
 }
Ejemplo n.º 23
0
 public static void logCallback(string log, string stackTrace, UnityEngine.LogType _type)
 {
     if (!sSaveToFileLogTypeList.ContainsKey(_type))
     {
         return;
     }
     SaveToFile(_type.ToString(), log, stackTrace, _type);
 }
Ejemplo n.º 24
0
 private void HandleLog(string logString, string stackTrace, UnityEngine.LogType type)
 {
     if (!m_UseMessageReceived)
     {
         return;
     }
     AddLog(logString + "\n" + stackTrace, JerryDebugUGUI.LogTypeUnity2Custom(type), Enum_LogTag.All, false, false);
 }
Ejemplo n.º 25
0
        private void HandleOutputMessage(string message, string stackTrace, UnityEngine.LogType logType)
        {
            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            this.Write(logType, string.Concat(message, Environment.NewLine, stackTrace));
        }
Ejemplo n.º 26
0
        private static void LogDebug(UnityEngine.LogType type, string log)
        {
            if (!debugEnabled)
            {
                return;
            }

            Log(type, log);
        }
Ejemplo n.º 27
0
        public void LogMessageReceived(string condition, string stackTrace, UnityEngine.LogType type)
        {
            LogType log_type = UnityLogTypeToFastLogType(type);

            if (log_type == LogType.ERROR)
            {
                MessageWindowError($"{condition}\n\nStackTrace: {stackTrace}");
            }
        }
Ejemplo n.º 28
0
    private void DebugCallBack(string condition, string stacktrace, UnityEngine.LogType type)
    {
        GameObject logMessage = Instantiate(debugLogPrefab, contentList);

        logMessage.GetComponentInChildren <Text>().text = condition + "\n" + stacktrace;
        Color background = (type == LogType.Warning ? Color.yellow : (type == LogType.Error ? Color.red : Color.white));

        background.a = 0.4f;
        logMessage.GetComponent <Image>().color = background;
    }
Ejemplo n.º 29
0
 private static void OnLogCallback(string condition, string stacktrace, UnityEngine.LogType type)
 {
     if (LogCallbackEvent != null)
     {
         lock (LogCallbackEvent)
         {
             LogCallbackEvent(condition, stacktrace, type);
         }
     }
 }
Ejemplo n.º 30
0
        public void LogFormat(UnityEngine.LogType logType, UnityEngine.Object context, string format, params object[] args)
        {
            streamWriter.WriteLine($"{System.DateTime.Now.ToString("HH:mm:ss:ffff")}|{logType}|{string.Format(format, args)}");
            streamWriter.Flush();

            PushLogIntoLogWindow($"{System.DateTime.Now.ToString("HH:mm:ss:ffff")}|{logType}|{string.Format(format, args)}");
#if UNITY_EDITOR
            //unityDefaultLogHandler.LogFormat(logType, context, format, args);
#endif
        }