mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-04-20 05:02:50 +08:00
refactor: ♻️ 异常请求输出追踪标识
This commit is contained in:
parent
93fe9e41b7
commit
ce697588f5
@ -128,8 +128,8 @@
|
||||
请求方式
|
||||
请求日志导出
|
||||
调试
|
||||
跟踪
|
||||
跟踪标识
|
||||
追踪
|
||||
追踪标识
|
||||
身份证
|
||||
运行
|
||||
通知
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 89586fd0c666cb907cb24690498c3211e578483f
|
||||
Subproject commit b7b73bbd298a5376eef8e250761760e9b4441eb0
|
@ -1 +1 @@
|
||||
Subproject commit c851ae3da25abd26364b0965d6d6affc76abee9f
|
||||
Subproject commit 433c4ee94c0d19ed98d1713885cd60bad3424c5f
|
@ -100,7 +100,7 @@ public record Sys_RequestLog : SimpleEntity, IFieldCreatedTime, IFieldOwner, IFi
|
||||
public virtual long? OwnerId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求跟踪标识
|
||||
/// 请求追踪标识
|
||||
/// </summary>
|
||||
[Column]
|
||||
[CsvIgnore]
|
||||
|
@ -22,4 +22,9 @@ public record RestfulInfo<T> : DataAbstraction
|
||||
/// </summary>
|
||||
/// <example>请求成功</example>
|
||||
public object Msg { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 追踪标识
|
||||
/// </summary>
|
||||
public Guid? TraceId { get; set; }
|
||||
}
|
@ -76,6 +76,6 @@ public sealed record ExportRequestLogRsp : QueryRequestLogRsp
|
||||
/// <inheritdoc />
|
||||
[CsvIndex(7)]
|
||||
[CsvIgnore(false)]
|
||||
[CsvName(nameof(Ln.跟踪标识))]
|
||||
[CsvName(nameof(Ln.追踪标识))]
|
||||
public override Guid TraceId { get; init; }
|
||||
}
|
@ -35,7 +35,7 @@ public abstract class ApiResultHandler<T>
|
||||
var result = RestfulResult(errorCode, metadata.Data
|
||||
, naException is NetAdminValidateException vEx
|
||||
? vEx.ValidateResults
|
||||
: naException?.Message ?? errorCode.ResDesc<ErrorCodes>());
|
||||
: naException?.Message ?? errorCode.ResDesc<ErrorCodes>(), context.HttpContext.GetTraceId());
|
||||
|
||||
SetErrorCodeToHeader(context.HttpContext, errorCode);
|
||||
|
||||
@ -95,9 +95,9 @@ public abstract class ApiResultHandler<T>
|
||||
/// <summary>
|
||||
/// 返回 RESTful 风格结果集
|
||||
/// </summary>
|
||||
private static T RestfulResult(ErrorCodes errorCode, object data = default, object message = default)
|
||||
private static T RestfulResult(ErrorCodes errorCode, object data = null, object message = null, Guid? traceId = null)
|
||||
{
|
||||
return new T { Code = errorCode, Data = data, Msg = message };
|
||||
return new T { Code = errorCode, Data = data, Msg = message, TraceId = traceId };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -7,10 +7,10 @@ namespace NetAdmin.Infrastructure.Enums;
|
||||
public enum LogLevels
|
||||
{
|
||||
/// <summary>
|
||||
/// 跟踪
|
||||
/// 追踪
|
||||
/// </summary>
|
||||
[Display(Name = "[gray]TCE[/]", ShortName = "TCE")]
|
||||
[ResourceDescription<Ln>(nameof(Ln.跟踪))]
|
||||
[ResourceDescription<Ln>(nameof(Ln.追踪))]
|
||||
Trace = 0
|
||||
|
||||
,
|
||||
|
@ -24,7 +24,7 @@ public static class HttpContextExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取跟踪标识
|
||||
/// 获取追踪标识
|
||||
/// </summary>
|
||||
public static Guid GetTraceId(this HttpContext me)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user