예제 #1
0
    private static void LogCallback(string condition, string stackTrace, LogType type)
    {
        // 将Log写入文件
        if (EntryPoint.Instance.IsToWriteLogFile && CLogExtension.IsIncluded(EntryPoint.Instance.WriteLogLevel, type))
        {
            WriteUnityLog2File(condition, stackTrace, type);
        }

        // 将Log缓存,以便在Debug面板显示
        if (EntryPoint.Instance.GameCustomConfigParams.EnableLogCache4Debug)
        {
            CacheLog4Debug(type, condition);
            if (type != LogType.Log && type != LogType.Warning && !string.IsNullOrEmpty(stackTrace))
            {
                CacheLog4Debug(type, stackTrace);
            }
        }
    }
예제 #2
0
    public static void Init()
    {
        CUnityHelper.RegisterLogCallback(LogCallback);

        CreateLogFiles();

        var logString = HobaText.Format("[systeminfo] {0}\n[applicationInfo] {1}", CLogExtension.GenerateDeviceInfo(), CLogExtension.GenerateApplicationInfo());

        WriteLogImp(logString);

        if (EntryPoint.Instance.GameCustomConfigParams.EnableLogCache4Debug && _LogDebugFormats == null)
        {
            _LogDebugFormats = new []
            {
                "<color='#ff0000'>[Error] {0} </color>\n",     // 0 LogType.Error
                "<color='#FFB90F'>[Assert] {0} </color>\n",    // 1 LogType.Assert
                "<color='#ffff00'>[Warning] {0} </color>\n",   // 2 LogType.Warning
                "<color='#ffffff'>[Log] {0} </color>\n",       // 3 LogType.Log
                "<color='#FF8247'>[Exception] {0} </color>\n", // 4 LogType.Exception
                "<color='#8B8B00'>[Unknown] {0} </color>\n",   // 未知类型
            };
        }
    }