v7.3.2018.0614   重构高性能资源池,减少GC压力,增加线程池,让异步任务得到平等竞争CPU的机会
大石头 authored at 2018-06-14 17:56:44
1.74 KiB
X
using System;
using System.Diagnostics;
using System.Threading;
using NewLife.Log;
using XCode.Model;

namespace XCode.DataAccessLayer
{
    partial class DAL
    {
        static DAL() { InitLog(); }

        #region Sql日志输出
        /// <summary>是否调试</summary>
        public static Boolean Debug { get; set; } = Setting.Current.Debug;

        /// <summary>输出日志</summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public static void WriteLog(String format, params Object[] args)
        {
            if (!Debug) return;

            //InitLog();
            XTrace.WriteLine(format, args);
        }

        /// <summary>输出日志</summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        [Conditional("DEBUG")]
        public static void WriteDebugLog(String format, params Object[] args)
        {
            if (!Debug) return;

            //InitLog();
            XTrace.WriteLine(format, args);
        }

        static Int32 hasInitLog = 0;
        internal static void InitLog()
        {
            if (Interlocked.CompareExchange(ref hasInitLog, 1, 0) > 0) return;

            // 输出当前版本
            System.Reflection.Assembly.GetExecutingAssembly().WriteVersion();
        }
        #endregion

        #region 辅助函数
        /// <summary>已重载。</summary>
        /// <returns></returns>
        public override String ToString() { return Db.ToString(); }

        /// <summary>建立数据表对象</summary>
        /// <returns></returns>
        internal static IDataTable CreateTable() { return XCodeService.CreateTable(); }
        #endregion
    }
}