| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System;
- namespace Abp.Auditing
- {
- /// <summary>
- /// This informations are collected for an <see cref="AuditedAttribute"/> method.
- /// </summary>
- public class AuditInfo
- {
- /// <summary>
- /// TenantId.
- /// </summary>
- public int? TenantId { get; set; }
-
- /// <summary>
- /// UserId.
- /// </summary>
- public long? UserId { get; set; }
- /// <summary>
- /// ImpersonatorUserId.
- /// </summary>
- public long? ImpersonatorUserId { get; set; }
- /// <summary>
- /// ImpersonatorTenantId.
- /// </summary>
- public int? ImpersonatorTenantId { get; set; }
- /// <summary>
- /// Service (class/interface) name.
- /// </summary>
- public string ServiceName { get; set; }
-
- /// <summary>
- /// Executed method name.
- /// </summary>
- public string MethodName { get; set; }
- /// <summary>
- /// Calling parameters.
- /// </summary>
- public string Parameters { get; set; }
- /// <summary>
- /// Start time of the method execution.
- /// </summary>
- public DateTime ExecutionTime { get; set; }
- /// <summary>
- /// Total duration of the method call.
- /// </summary>
- public int ExecutionDuration { get; set; }
- /// <summary>
- /// IP address of the client.
- /// </summary>
- public string ClientIpAddress { get; set; }
-
- /// <summary>
- /// Name (generally computer name) of the client.
- /// </summary>
- public string ClientName { get; set; }
- /// <summary>
- /// Browser information if this method is called in a web request.
- /// </summary>
- public string BrowserInfo { get; set; }
- /// <summary>
- /// Optional custom data that can be filled and used.
- /// </summary>
- public string CustomData { get; set; }
-
- /// <summary>
- /// Exception object, if an exception occurred during execution of the method.
- /// </summary>
- public Exception Exception { get; set; }
- public override string ToString()
- {
- var loggedUserId = UserId.HasValue
- ? "user " + UserId.Value
- : "an anonymous user";
- var exceptionOrSuccessMessage = Exception != null
- ? "exception: " + Exception.Message
- : "succeed";
- return $"AUDIT LOG: {ServiceName}.{MethodName} is executed by {loggedUserId} in {ExecutionDuration} ms from {ClientIpAddress} IP address with {exceptionOrSuccessMessage}.";
- }
- }
- }
|