private AuditLogger(AuditLogEntry logEntry) { Providers = new ServiceLocatableDictionary<AuditLogProviderBase>(null); this.logEntry = logEntry; ConfigManager.GetConfigurationSection<AuditTrailSettings>() .Configure(ServiceLocatorFactory.GetServiceLocator()); }
protected override void WriteCore(AuditLogEntry logEntry) { Guard.ArgumentNotNull(logEntry, "logEntry"); foreach (var current in Listeners) { current.Write(logEntry); } }
/// <summary> /// Writes the specified audit log entry. /// </summary> /// <param name="logEntry">The audit log entry.</param> public void Write(AuditLogEntry logEntry) { Guard.ArgumentNotNull(logEntry, "logEntry"); if (Filter.Match(logEntry)) { WriteCore(logEntry); } }
/// <summary> /// Create <see cref="T:Cedar.Framework.AuditTrail.AuditLogger" /> based on the specified function name. /// </summary> /// <param name="functionName">Name of the function.</param> /// <returns>The creatd <see cref="T:Cedar.Framework.AuditTrail.AuditLogger" />.</returns> public static AuditLogger CreateAuditLogger(string functionName) { Guard.ArgumentNotNullOrEmpty(functionName, "functionName"); if (string.IsNullOrEmpty(ApplicationContext.Current.UserName)) { //throw new InvalidOperationException(Resources.ExceptionCurrentUserNameNotExists); } if (string.IsNullOrEmpty(ApplicationContext.Current.TransactionId)) { //throw new InvalidOperationException(Resources.ExceptionCurrentTransactionIdNotExists); } var auditLogEntry = new AuditLogEntry(functionName, null, null, null, null); return new AuditLogger(auditLogEntry); }
/// <summary> /// Writes the specified audit log entry. /// </summary> /// <param name="logEntry">The audit log entry.</param> protected override void WriteCore(AuditLogEntry logEntry) { Guard.ArgumentNotNull(logEntry, "logEntry"); RedisDatabaseWrapper.StringSet($"{logEntry.FunctionName}:{logEntry.TransactionId}", JsonConvert.SerializeObject(logEntry)); }
/// <summary> /// Matches the specified log entry. /// </summary> /// <param name="logEntry">The log entry.</param> /// <returns> /// A <see cref="T:System.Boolean" /> value indicating whether to match the specified log entry. /// </returns> public override bool Match(AuditLogEntry logEntry) { Guard.ArgumentNotNull(logEntry, "logEntry"); return false; }
/// <summary> /// Matches the specified log entry. /// </summary> /// <param name="logEntry">The log entry.</param> /// <returns> /// A <see cref="T:System.Boolean" /> value indicating whether to match the specified log entry. /// </returns> public abstract bool Match(AuditLogEntry logEntry);
/// <summary> /// Writes the specified audit log entry. /// </summary> /// <param name="logEntry">The audit log entry.</param> protected abstract void WriteCore(AuditLogEntry logEntry);