void ILogWriter.Write(ILogEntry entry) { if (entry == null) { throw new ArgumentNullException("entry"); } if (typeof(TLogEntry) != entry.GetType()) { throw new ArgumentOutOfRangeException("entry", string.Format(CultureInfo.InvariantCulture, "Unexpected Log Entry: {0} ", entry.GetType())); } Write((TLogEntry)entry); }
private static Dictionary <string, object> BuilPropertiesFromEntry(ILogEntry entry) { if (entry == null) { return(new Dictionary <string, object>()); } var entryProperties = entry.GetType().GetProperties(); var properties = new Dictionary <string, object>(entryProperties.Length); foreach (var property in entryProperties) { var name = property.Name; var value = property.GetValue(entry); properties.Add(name, value); } return(properties); }
public virtual void Write(ILogEntry entry) { try { if (entry is ITransactionEntry) { WriteTransaction((ITransactionEntry)entry); } else if (entry is IExceptionEntry) { WriteException((IExceptionEntry)entry); } else if (entry is IEventEntry) { WriteEvent((IEventEntry)entry); } else { throw new NotSupportedException(string.Format(LogResources.UnSupportedLogEntryType, entry.GetType().AssemblyQualifiedName)); } } catch (LogException) { throw; } catch (Exception ex) { FailSafeLog(ex); } }