public void Append(string name, byte[] data, long expectedVersion = -1) { lock (this.locker) { var version = this.name_events.ContainsKey(name) ? this.name_events[name].Last().Version : 0; if (version != expectedVersion) { throw new AppendOnlyStoreConcurrencyException(version, expectedVersion, name); } long next = 0; if (!this.name_events.ContainsKey(name)) { this.name_events[name] = new List <DataWithVersionAndName>(); } else { next = this.name_events[name].Last().Version; } next++; var stored = new DataWithVersionAndName() { Data = data, Name = name, Version = next }; this.all_events.Add(stored); this.name_events[name].Add(stored); Logger.Debug("Saved name: " + name); } }
public async Task <bool> Initialize() { try { await this.projections.CreateIfNotExistsAsync(); await this.table.CreateIfNotExistsAsync(); } catch (StorageException ex) { Logger.DebugFormat("Failed to initialize, best guess is bad naming of table. Check azure naming guidelines."); Logger.InfoFormat("Error: {0} with status code: {1}. Extended info: {2} ({3})", ex.RequestInformation.HttpStatusMessage, ex.RequestInformation.HttpStatusCode, ex.RequestInformation.ExtendedErrorInformation.ErrorMessage, ex.RequestInformation.ExtendedErrorInformation.ErrorCode); Logger.Debug(ex.ToString()); return(false); } return(true); }
public void AquireLease() { //var blobReference = this.container.GetBlobReferenceFromServer("lock"); Logger.Debug("Requesting lease...."); this.lease = this.container.AcquireLease(TimeSpan.FromSeconds(15), this.instanceId); if (string.IsNullOrEmpty(lease)) { this.Exception = new Exception("Could not aquire lease."); Logger.Info("Got exception on lease: ", this.Exception); } else { this.Exception = null; Logger.DebugFormat("Got lease.... {0}", this.lease); } }
public void Log(LogLevel level, Exception ex, string messageFormatString, params object[] formatStringParameters) { switch (level) { case LogLevel.Debug: { TheLogger.Debug(CallingMethodName + " " + FormattedString(messageFormatString, formatStringParameters) + ex.ToFullException() , ex); break; } case LogLevel.Info: { TheLogger.Info(CallingMethodName + " " + FormattedString(messageFormatString, formatStringParameters) + ex.ToFullException(), ex); break; } case LogLevel.Warn: { TheLogger.Warn(CallingMethodName + " " + FormattedString(messageFormatString, formatStringParameters) + ex.ToFullException(), ex); break; } case LogLevel.Error: Error(ex, messageFormatString, formatStringParameters); break; case LogLevel.Fatal: Fatal(ex, messageFormatString, formatStringParameters); break; default: throw new InvalidOperationException("Unknown LogLevel"); } }
public void Debug(string messageFormatString, params object[] formatStringParameters) { TheLogger.Debug(CallingMethodName + ": " + FormattedString(messageFormatString, formatStringParameters)); }