Skip to content

Commit

Permalink
删除没有太大意义的eventid, 由业务系统自行定义
Browse files Browse the repository at this point in the history
  • Loading branch information
snys98 committed May 7, 2021
1 parent ad73621 commit c7991d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 55 deletions.
42 changes: 1 addition & 41 deletions Zero.Logging.Commom/EventIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Geexbox.Logging.ElasticSearch.ZeroLoggingCommom
{
public struct GeexboxEventId
public class GeexboxEventId
{
public EventId val;

Expand All @@ -16,46 +16,6 @@ public GeexboxEventId(EventId eventId)
this.val = eventId;
}

public static GeexboxEventId RemoteEndPointRequest
{
get
{
return new GeexboxEventId(new EventId(nameof(RemoteEndPointRequest).GetHashCode(), nameof(RemoteEndPointRequest)));
}
}

public static GeexboxEventId RemoteEndPointResponse
{
get
{
return new GeexboxEventId(new EventId(nameof(RemoteEndPointResponse).GetHashCode(), nameof(RemoteEndPointResponse)));
}
}

public static GeexboxEventId AuditLog
{
get
{
return new GeexboxEventId(new EventId(nameof(AuditLog).GetHashCode(), nameof(AuditLog)));
}
}

public static GeexboxEventId ExceptionFilter
{
get
{
return new GeexboxEventId(new EventId(nameof(ExceptionFilter).GetHashCode(), nameof(ExceptionFilter)));
}
}

public static GeexboxEventId BackgroundExceptionFilter
{
get
{
return new GeexboxEventId(new EventId(nameof(BackgroundExceptionFilter).GetHashCode(), nameof(BackgroundExceptionFilter)));
}
}

public override string ToString()
{
return val.ToString();
Expand Down
16 changes: 2 additions & 14 deletions Zero.Logging.Elasticsearch/EsLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,9 @@ public void Log(DateTimeOffset timestamp, LogLevel logLevel, EventId eventId, ob
WriteException(jsonData["exceptions"] as List<ExceptionModel>, exception, 0);
}

if (eventId == GeexboxEventId.RemoteEndPointRequest)
if (state != default)
{
jsonData["request"] = state.FirstOrDefault();
}
else if (eventId == GeexboxEventId.RemoteEndPointResponse)
{
jsonData["response"] = state.FirstOrDefault();
}
else if (eventId == GeexboxEventId.AuditLog)
{
jsonData["auditInfo"] = state.FirstOrDefault();
}
else
{
jsonData["data"] = state;
jsonData["data"] = state.FirstOrDefault();
}

_provider.AddMessage(timestamp, Newtonsoft.Json.JsonConvert.SerializeObject(jsonData, _serializerSettings));
Expand Down

0 comments on commit c7991d6

Please sign in to comment.