Пример #1
0
        // ReSharper restore FunctionNeverReturns

        private static void WriteToLog(RecordInfo info)
        {
            try
            {
                if (Listener != null)
                {
                    Listener.Trace(info);
                    Thread.Sleep(0);
                }
                else
                {
                    SystemTrace(info.Message);
                }
            }
            catch (Exception ex)
            {
                SystemTrace("日志侦听器发生错误", ex);
            }
            try
            {
                if (info.Type == LogType.Trace)
                {
                    TxtRecorder.RecordTrace(info.Message);
                    return;
                }
                if (info.Type == LogType.Monitor)
                {
                    TxtRecorder.RecordTrace(info.Message, ".monitor");
                    return;
                }
#if SERVICE
                if ((info.Type == LogType.Error || info.Type == LogType.Exception) && !IsTextRecorder)
                {
                    TxtRecorder.Recorder.RecordLog(info);
                }
                Recorder?.RecordLog(info);
#else
                Recorder.RecordLog(info);
#endif
            }
            catch (Exception ex)
            {
                SystemTrace("日志写入发生错误", ex);
            }
        }
Пример #2
0
        // ReSharper restore FunctionNeverReturns

        private static void WriteToLog(RecordInfo info)
        {
            try
            {
                if (Listener != null)
                {
                    Listener.Trace(info);
                    Thread.SpinWait(0);
                }
                else
                {
                    SystemTrace(info.Message);
                }
            }
            catch (Exception ex)
            {
                SystemTrace("日志侦听器发生错误", ex);
            }
            try
            {
                switch (info.Type)
                {
                case LogType.Trace:
                    TxtRecorder.RecordTrace(info.Message);
                    return;

                case LogType.Monitor:
                    TxtRecorder.RecordTrace(info.Message, ".monitor");
                    return;
                }
                if (!IsTextRecorder && info.Type > LogType.System)
                {
                    BaseRecorder.RecordLog(info);
                }
                Recorder.RecordLog(info);
            }
            catch (Exception ex)
            {
                SystemTrace("日志写入发生错误", ex);
            }
        }