public static void UseWinFormControl(this Control control, Boolean useFileLog = true, Int32 maxLines = 1000) { var clg = _Log as TextControlLog; var ftl = _Log as TextFileLog; if (_Log is CompositeLog cmp) { ftl = cmp.Get<TextFileLog>(); clg = cmp.Get<TextControlLog>(); } // 控制控制台日志 if (clg == null) clg = new TextControlLog(); clg.Control = control; clg.MaxLines = maxLines; if (!useFileLog) { Log = clg; if (ftl != null) ftl.Dispose(); } else { if (ftl == null) ftl = TextFileLog.Create(null); Log = new CompositeLog(clg, ftl); } }
public static ILog Combine(this Control control, ILog log, Int32 maxLines = 1000) { //if (control == null || log == null) return log; var clg = new TextControlLog { Control = control, MaxLines = maxLines }; return(new CompositeLog(log, clg)); }
/// <summary>控件绑定到日志,生成混合日志</summary> /// <param name="control"></param> /// <param name="log"></param> /// <param name="maxLines"></param> /// <returns></returns> public static ILog Combine(this Control control, ILog log, Int32 maxLines = 1000) { if (control == null || log == null) { return(log); } var clg = new TextControlLog(); clg.Control = control; clg.MaxLines = maxLines; return(new CompositeLog(log, clg)); }