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

namespace NewLife.Net.Sockets
{
    /// <summary>网络基类,提供资源释放和日志输出的统一处理</summary>
    public abstract class Netbase : DisposeBase
    {
        #region 构造销毁
        static Netbase()
        {
            // 输出网络库版本
            Assembly.GetExecutingAssembly().WriteVersion();
        }

        /// <summary>实例化</summary>
        public Netbase()
        {
            if (Setting.Current.Debug) Log = XTrace.Log;
        }
        #endregion

        #region 日志
        /// <summary>日志提供者</summary>
        public ILog Log { get; set; } = Logger.Null;

        /// <summary>写日志</summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public virtual void WriteLog(String format, params Object[] args)
        {
            Log.Info(format, args);
        }

        /// <summary>写调试日志</summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        [Conditional("DEBUG")]
        public virtual void WriteDebugLog(String format, params Object[] args)
        {
            Log.Debug(format, args);
        }
        #endregion
    }
}