/// <summary> /// Copy constructor. /// </summary> /// <param name="aMemoryLogger">The MemoryLogger to copy.</param> public MemoryLogger(MemoryLogger aMemoryLogger) : this(aMemoryLogger.Capacity) { LogEntries = (ArrayList)((ArrayList)aMemoryLogger.LogEntries).Clone(); }
/// <summary> /// SetForSending the LogEntry to the MemoryLogger, then start the retrying thread. /// </summary> /// <param name="aLogEntry">The LogEntry to log.</param> /// <returns>Always returns true.</returns> private bool HandleLogFailure(LogEntry aLogEntry) { MemoryLogger.DoLog(aLogEntry); StartThread(); return(true); }
/// <summary> /// Attempt to transfer the stored LogEntries to their proper destination. /// </summary> /// <returns>true if all LogEntries transfered, false otherwise.</returns> private bool Transfer() { lock (this) { return(MemoryLogger.TransferTo(Logger)); } }
/// <summary> /// Create a new instance of InsistentLogger. /// </summary> /// <param name="aLogger">The actual Logger that should eventually receive LogEntries.</param> /// <param name="capacity">The maximum number of LogEntries that should be stored for retrying.</param> /// <param name="anIntervalSeconds">The number of seconds between each retry at logging.</param> public InsistentLogger(Logger aLogger, int capacity, int anIntervalSeconds) : this() { Logger = aLogger; MemoryLogger = new MemoryLogger(capacity); IntervalSeconds = anIntervalSeconds; }