Пример #1
0
        public static void Release()
        {
#if LOG_FILE
            if (writer != null)
            {
                writer.Release();
                writer = null;
            }
#endif
        }
Пример #2
0
        /// <summary>
        /// 写日志。
        /// </summary>
        /// <param name="message">日志内容</param>
        private static void LogFile(object message, LogType level)
        {
#if LOG_FILE
            if (message == null || level == null)
            {
                return;
            }
            string text  = message is string?(string)message : message.ToString();
            string stack = string.Empty;
            string type  = string.Empty;
            switch (level)
            {
            case LogType.Assert:
                type  = " [ASSERT]: ";
                stack = GetStackInfo();
                break;

            case LogType.Error:
                type  = " [ERROR]: ";
                stack = GetStacksInfo();
                break;

            case LogType.Exception:
                type  = " [EXCEPTION]: ";
                stack = GetStacksInfo();
                break;

            case LogType.Log:
                type  = " [INFO]: ";
                stack = GetStackInfo();
                break;

            case LogType.Warning:
                type  = " [WARNING]: ";
                stack = GetStackInfo();
                break;

            default:
                break;
            }
            if (writer == null)
            {
                writer = new LogFileWriter();
            }
            writer.WriteLog(string.Concat(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff"), type, text, "\n", SHOW_STACK ? stack : ""));
#endif
        }