public void OnTriggerNotification(string result) { if (Notifications == null || !Notifications.Any() || NotifyCondition == NotifyCondition.None) { return; } var subject = $"{(Debugger.IsAttached ? "`DEBUG MODE`" : "")} **{Name}**\n" + $"----------------------------------------"; var body = $"\nResult: `{result}` " + $"\nAction: `{ActionName}` \n"; if (ActionParameters?.Any() == true) { body += "Arguments: ```\n"; foreach (var arg in ActionParameters.Where((k, v) => !String.IsNullOrEmpty(v.ToString()))) { var val = string.Concat(arg.Value.ToString() .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) .Select(x => $"{x}\n\t")); val = val.Remove(val.LastIndexOf('\t')); body += $" • {arg.Key}: {val}"; } body = body.Replace("\"", "") + "\n```"; } foreach (var notify in Notifications.Where(n => CompareByNotifyCondition(result))) { try { #if !TestWithoutNotify notify.Notify(body, subject); #endif } catch (Exception exp) { Nlogger.Error(exp); } } }
/// <summary> /// 记录Error级日志 /// </summary> /// <param name="err">程序异常</param> /// <param name="msg">格式化消息</param> /// <param name="args">格式参数</param> public void Error(Exception err, string msg, params object[] args) => Nlogger.Error(err, msg, args);
/// <summary> /// 记录Error级日志 /// </summary> /// <param name="msg">格式化消息</param> /// <param name="args">格式参数</param> public void Error(string msg, params object[] args) => Nlogger.Error(msg, args);