using System;
namespace Abp.Auditing
{
///
/// This informations are collected for an method.
///
public class AuditInfo
{
///
/// TenantId.
///
public int? TenantId { get; set; }
///
/// UserId.
///
public long? UserId { get; set; }
///
/// ImpersonatorUserId.
///
public long? ImpersonatorUserId { get; set; }
///
/// ImpersonatorTenantId.
///
public int? ImpersonatorTenantId { get; set; }
///
/// Service (class/interface) name.
///
public string ServiceName { get; set; }
///
/// Executed method name.
///
public string MethodName { get; set; }
///
/// Calling parameters.
///
public string Parameters { get; set; }
///
/// Start time of the method execution.
///
public DateTime ExecutionTime { get; set; }
///
/// Total duration of the method call.
///
public int ExecutionDuration { get; set; }
///
/// IP address of the client.
///
public string ClientIpAddress { get; set; }
///
/// Name (generally computer name) of the client.
///
public string ClientName { get; set; }
///
/// Browser information if this method is called in a web request.
///
public string BrowserInfo { get; set; }
///
/// Optional custom data that can be filled and used.
///
public string CustomData { get; set; }
///
/// Exception object, if an exception occurred during execution of the method.
///
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}.";
}
}
}