static public void Entry(ClassExp.EXP_CODES code, SEV_CODES sev, string msg, string loc, string who) { lock (HelperLock) { try { if (MAX_SEV.Equals(-1) || MAX_SEV >= Convert.ToInt32(sev)) { string fmtMsg = ""; if (code != ClassExp.EXP_CODES.EXP_OK) { fmtMsg += code.ToString() + ": "; } if (loc.Length > 0) { fmtMsg += " : (- " + loc + " -) "; } if (who.Length > 0) { fmtMsg += " : (id-" + who + " -) "; } fmtMsg += msg; LogLedger entry = new LogLedger(Convert.ToInt32(sev), fmtMsg); /* Write to Database */ CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("AzureWebJobsStorage")); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference(LogTableName); TableOperation addOperation = TableOperation.Insert(entry); table.ExecuteAsync(addOperation); } } catch { }// Not much recourse if this fails. } }
/// <summary> /// Remove a Log Record. /// </summary> static public void Delete(string key) { lock (HelperLock) { try { LogLedger entry = new LogLedger(key); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("AzureWebJobsStorage")); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference(LogTableName); TableOperation delOperation = TableOperation.Delete(entry); table.ExecuteAsync(delOperation); } catch (Exception ex) { // The Storage Exceptions all bury their message in the inner exception, so we need to dig it out. string realMsg = ParseTSErr(ex.InnerException.Message); throw new ClassExp(ClassExp.EXP_CODES.EXP_TS_FAIL, "ServiceLedger.Delete", realMsg); } } }