[fix]Config创建默认配置文件的开关Runtime.CreateConfigOnMissing,仅需对自动创建生效,而不应该阻止用户主动Save
智能大石头 authored at 2024-08-09 00:30:41 石头 committed at 2024-08-10 14:22:24
965.00 B
X
using System;

namespace NewLife.Log
{
    /// <summary>依托于动作的日志类</summary>
    public class ActionLog : Logger
    {
        /// <summary>方法</summary>
        public Action<String, Object[]> Method { get; set; }

        /// <summary>使用指定方法否则动作日志</summary>
        /// <param name="action"></param>
        public ActionLog(Action<String, Object[]> action) { Method = action; }

        /// <summary>写日志</summary>
        /// <param name="level"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        protected override void OnWrite(LogLevel level, String format, params Object[] args)
        {
            if (Method != null) Method(format, args);
        }

        /// <summary>已重载</summary>
        /// <returns></returns>
        public override String ToString()
        {
            return Method + "";
        }
    }
}