You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
50 lines
1.5 KiB
3 weeks ago
|
using Wood.Entity.SystemManage;
|
||
|
using Wood.Util;
|
||
|
|
||
|
namespace Wood.EventBus.Events
|
||
|
{
|
||
|
public class LogExceptionEvent : IntegrationEvent
|
||
|
{
|
||
|
public LogExceptionEvent(object? payload)
|
||
|
{
|
||
|
Payload = payload;
|
||
|
}
|
||
|
|
||
|
public static LogExceptionEvent NewEvent()
|
||
|
{
|
||
|
LogExceptionEntity entity = new LogExceptionEntity();
|
||
|
entity.LogDateTime = DateTime.Now;
|
||
|
return new LogExceptionEvent(entity);
|
||
|
}
|
||
|
|
||
|
public static LogExceptionEvent NewEvent(Exception ex)
|
||
|
{
|
||
|
LogExceptionEntity entity = new LogExceptionEntity();
|
||
|
entity.LogDateTime = DateTime.Now;
|
||
|
entity.ExceptionStackTrace = ex.StackTrace;
|
||
|
entity.Exception = ex.Message;
|
||
|
entity.Message = ex.GetFullExceptionMessage();
|
||
|
return new LogExceptionEvent(entity);
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 发布错误日志事件
|
||
|
/// </summary>
|
||
|
/// <param name="ex">错误信息</param>
|
||
|
/// <param name="requestUrl">来源url 或者 jobid</param>
|
||
|
/// <param name="controller">来源controller 或者 job class name </param>
|
||
|
/// <param name="action">来源action 或者 job method name </param>
|
||
|
public static LogExceptionEvent NewEvent(Exception ex, string requestUrl, string controller, string action)
|
||
|
{
|
||
|
LogExceptionEntity entity = new LogExceptionEntity();
|
||
|
entity.LogDateTime = DateTime.Now;
|
||
|
entity.ExceptionStackTrace = ex.StackTrace;
|
||
|
entity.Exception = ex.Message;
|
||
|
entity.Message = ex.GetFullExceptionMessage();
|
||
|
entity.ControllerName = controller;
|
||
|
entity.ActionName = action;
|
||
|
entity.RequestUrl = requestUrl;
|
||
|
return new LogExceptionEvent(entity);
|
||
|
}
|
||
|
}
|
||
|
}
|