async Task LogPreparation(string task, int instanceId, string message) { var log = EsbLog.Create(task, EsbLogLevel.Message, EsbOperation.Preparation, HttpContext.Connection.RemoteIpAddress.ToString(), instanceId, message); _esbModelContext.Add(log); await _esbModelContext.SaveChangesAsync(); }
async Task LogApiError(string task, int instanceId, string invokedUrl, string message) { var log = EsbLog.Create(task, EsbLogLevel.Warning, EsbOperation.Respond, HttpContext.Connection.RemoteIpAddress.ToString(), instanceId, message, invokedUrl); _esbModelContext.Add(log); await _esbModelContext.SaveChangesAsync(); }
async Task LogEnd(string task, int instanceId, string invokedUrl, int outLength) { var log = EsbLog.Create(task, EsbLogLevel.Message, EsbOperation.Respond, HttpContext.Connection.RemoteIpAddress.ToString(), instanceId, string.Empty, invokedUrl, 0, outLength); _esbModelContext.Add(log); await _esbModelContext.SaveChangesAsync(); }
async Task LogStart(string task, int instanceId) { var log = EsbLog.Create(task, EsbLogLevel.Message, EsbOperation.Incoming, HttpContext.Connection.RemoteIpAddress.ToString(), instanceId, string.Empty, string.Empty, (int)Request.ContentLength); _esbModelContext.Add(log); await _esbModelContext.SaveChangesAsync(); }
/// <summary> /// 自动记录错误日志, 记录退出返回日志。 /// 因此,调用该方法应该直接Return,防止在调用后又执行代码。 /// </summary> async Task <ContentResult> Error(int code, string message, string task, int instanceId, EsbOperation period, string invokedUrl = "") { var log = EsbLog.Create(task, EsbLogLevel.Failure, period, HttpContext.Connection.RemoteIpAddress.ToString(), instanceId, message, invokedUrl); _esbModelContext.Add(log); await _esbModelContext.SaveChangesAsync(); ResponseBody response = new ResponseBody(code, message, "", SimpleRESTfulReturn.Empty); await LogEnd(task, instanceId, invokedUrl, message.Length + 4); return(Content(response.Value)); }