Browse Source

sync auding long module

master
guotianliang 3 years ago
parent
commit
66e2cc683b
  1. 20
      modules/auditing/Sanhe.Abp.AuditLogging.Elasticsearch/Sanhe/Abp/AuditLogging/Elasticsearch/ElasticsearchAuditLogManager.cs
  2. 3
      modules/auditing/Sanhe.Abp.AuditLogging/Sanhe/Abp/AuditLogging/AuditLogAction.cs
  3. 2
      modules/common/Sanhe.Abp.Hangfire.Storage.PostgreSql/README.md
  4. 6
      modules/logging/Sanhe.Abp.Logging.Serilog.Elasticsearch/Sanhe/Abp/AuditLogging/Serilog/Elasticsearch/SerilogElasticsearchLoggingManager.cs

20
modules/auditing/Sanhe.Abp.AuditLogging.Elasticsearch/Sanhe/Abp/AuditLogging/Elasticsearch/ElasticsearchAuditLogManager.cs

@ -41,7 +41,6 @@ namespace Sanhe.Abp.AuditLogging.Elasticsearch
Logger = NullLogger<ElasticsearchAuditLogManager>.Instance; Logger = NullLogger<ElasticsearchAuditLogManager>.Instance;
} }
public virtual async Task<long> GetCountAsync( public virtual async Task<long> GetCountAsync(
DateTime? startTime = null, DateTime? startTime = null,
DateTime? endTime = null, DateTime? endTime = null,
@ -213,13 +212,20 @@ namespace Sanhe.Abp.AuditLogging.Elasticsearch
var auditLog = await _converter.ConvertAsync(auditLogInfo); var auditLog = await _converter.ConvertAsync(auditLogInfo);
var response = await client.IndexAsync( //var response = await client.IndexAsync(
auditLog, // auditLog,
(x) => x.Index(CreateIndex()) // (x) => x.Index(CreateIndex())
.Id(auditLog.Id), // .Id(auditLog.Id),
cancellationToken); // cancellationToken);
// 使用 Bulk 命令传输可能存在参数庞大的日志结构
var response = await client.BulkAsync(
dsl => dsl.Index(CreateIndex())
.Create<AuditLog>(ct =>
ct.Id(auditLog.Id)
.Document(auditLog)));
return response.Id; return response.Items?.FirstOrDefault()?.Id;
} }
protected virtual List<Func<QueryContainerDescriptor<AuditLog>, QueryContainer>> BuildQueryDescriptor( protected virtual List<Func<QueryContainerDescriptor<AuditLog>, QueryContainer>> BuildQueryDescriptor(

3
modules/auditing/Sanhe.Abp.AuditLogging/Sanhe/Abp/AuditLogging/AuditLogAction.cs

@ -41,7 +41,8 @@ namespace Sanhe.Abp.AuditLogging
ExtraProperties = new ExtraPropertyDictionary(actionInfo.ExtraProperties); ExtraProperties = new ExtraPropertyDictionary(actionInfo.ExtraProperties);
ServiceName = actionInfo.ServiceName; ServiceName = actionInfo.ServiceName;
MethodName = actionInfo.MethodName; MethodName = actionInfo.MethodName;
Parameters = actionInfo.Parameters.Length > 2000 ? "" : actionInfo.Parameters; Parameters = actionInfo.Parameters;
// Parameters = actionInfo.Parameters.Length > 2000 ? "" : actionInfo.Parameters;
} }
} }
} }

2
modules/common/Sanhe.Abp.Hangfire.Storage.PostgreSql/README.md

@ -1,4 +1,4 @@
# Sanhe.Abp.Hangfire.Dashboard # Sanhe.Abp.Hangfire.Storage.PostgreSql
Hangfire持久化PostgreSql Hangfire持久化PostgreSql

6
modules/logging/Sanhe.Abp.Logging.Serilog.Elasticsearch/Sanhe/Abp/AuditLogging/Serilog/Elasticsearch/SerilogElasticsearchLoggingManager.cs

@ -91,7 +91,8 @@ namespace Sanhe.Abp.AuditLogging.Serilog.Elasticsearch
(s) => s.Term( (s) => s.Term(
(t) => t.Field(GetField(nameof(SerilogInfo.Fields.UniqueId))).Value(id)), (t) => t.Field(GetField(nameof(SerilogInfo.Fields.UniqueId))).Value(id)),
(s) => s.Term( (s) => s.Term(
(t) => t.Field(GetField(nameof(SerilogInfo.Fields.TenantId))).Value(_currentTenant.GetId()))))), (t) => t.Field(GetField(nameof(SerilogInfo.Fields.TenantId))).Value(_currentTenant.GetId())))))
.Size(1),
cancellationToken); cancellationToken);
} }
else else
@ -118,7 +119,8 @@ namespace Sanhe.Abp.AuditLogging.Serilog.Elasticsearch
(q) => q.Bool( (q) => q.Bool(
(b) => b.Must( (b) => b.Must(
(s) => s.Term( (s) => s.Term(
(t) => t.Field(GetField(nameof(SerilogInfo.Fields.UniqueId))).Value(id))))), (t) => t.Field(GetField(nameof(SerilogInfo.Fields.UniqueId))).Value(id)))))
.Size(1),
cancellationToken); cancellationToken);
} }

Loading…
Cancel
Save