static void Main(string[] args) { var fd = GetFlogDetail("starting applicaction", null); Flogger.WriteDiagnostic(fd); var tracker = new PerfTracker("FloggingConsoloe_execution", fd.UserId, fd.UserName, fd.Location, fd.Product, fd.Layer); try { var ex = new Exception("Something bad has happened"); ex.Data.Add("input param", "nothing to see here"); throw ex; } catch (Exception ex) { fd = GetFlogDetail("", ex); Flogger.WriteError(fd); } fd = GetFlogDetail("use flogging detail", null); Flogger.WriteUsage(fd); fd = GetFlogDetail("stopping app", null); Flogger.WriteDiagnostic(fd); tracker.Stop(); }
public static void LogWebDiagnostic(string product, string layer, string message, Dictionary <string, object> diagnosticInfo = null) { var writeDiagnostics = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableDiagnostics"]); if (!writeDiagnostics) { return; } string userId, userName, location; var webInfo = GetWebFloggingData(out userId, out userName, out location); if (diagnosticInfo != null) { foreach (var key in diagnosticInfo.Keys) { webInfo.Add(key, diagnosticInfo[key]); } } var diagInfo = new FlogDetail() { Product = product, Layer = layer, Location = location, UserId = userId, UserName = userName, Hostname = Environment.MachineName, CorrelationId = HttpContext.Current.Session.SessionID, Message = message, AdditionalInfo = webInfo }; Flogger.WriteDiagnostic(diagInfo); }
static void Main(string[] args) { // diagnostic var flogDetail = GetFlogDetail("starting application", null); Flogger.WriteDiagnostic(flogDetail); // perf tracker var tracker = new PerfTracker("Flogger.Console Execution", "", flogDetail.UserName, flogDetail.Location, flogDetail.Product, flogDetail.Layer); // error try { var ex = new Exception("Something bad has happened"); ex.Data.Add("input param", "nothing to see here..."); throw ex; } catch (Exception ex) { flogDetail = GetFlogDetail("", ex); Flogger.WriteError(flogDetail); } flogDetail = GetFlogDetail("Flogging.Console Usage", null); Flogger.WriteUsage(flogDetail); flogDetail = GetFlogDetail("Stopping Flogging.Console", null); Flogger.WriteDiagnostic(flogDetail); tracker.Stop(); }
private static void WriteMessage() { if (!string.IsNullOrEmpty(_message)) { var d = Flogger.GetFlogDetail(_message, null); Flogger.WriteDiagnostic(d); WriteColor($"\n {_message}", ConsoleColor.DarkGreen); _message = ""; } }
internal static void LogIt(FlogDetail logEntry, string endpoint) { switch (endpoint) { case "Performance": Flogger.WritePerf(logEntry); break; case "Diagnostic": Flogger.WriteDiagnostic(logEntry); break; case "Error": Flogger.WriteError(logEntry); break; default: return; } }
// Requires EnableDiagnostics=true in web.config AppSettings public void Write([FromBody] FlogDetail logEntry) { Flogger.WriteDiagnostic(logEntry); }
static void Main(string[] args) { var fd = GetFlogDetail("starting application", null); Flogger.WriteDiagnostic(fd); var tracker = new PerfTracker("FloggerConsole_Execution", "", fd.UserName, fd.Location, fd.Product, fd.Layer); //try //{ // var ex = new Exception("Something bad has happened!"); // ex.Data.Add("input param", "nothing to see here"); // throw ex; //} //catch (Exception ex) //{ // fd = GetFlogDetail("", ex); // Flogger.WriteError(fd); //} var connStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); using (var db = new SqlConnection(connStr)) { db.Open(); try { //RAW ADO.NET //var rawAdoSp = new SqlCommand("CreateNewCustomer", db) //{ // CommandType = System.Data.CommandType.StoredProcedure //}; //rawAdoSp.Parameters.Add(new SqlParameter("@Name", "waytoolongforitsowngood")); //rawAdoSp.Parameters.Add(new SqlParameter("@TotalPurchases", 12000)); //rawAdoSp.Parameters.Add(new SqlParameter("@TotalReturns", 100.50M)); //rawAdoSp.ExecuteNonQuery(); var sp = new Sproc(db, "CreateNewCustomer"); sp.SetParam("@Name", "waytoolongforitsowngood"); sp.SetParam("@TotalPurchases", 12000); sp.SetParam("@TotalReturns", 100.50M); sp.ExecNonQuery(); } catch (Exception ex) { var efd = GetFlogDetail("", ex); Flogger.WriteError(efd); } try { // Dapper //db.Execute("CreateNewCustomer", new //{ // Name = "dappernametoolongtowork", // TotalPurchases = 12000, // TotalReturns = 100.50M //}, commandType: System.Data.CommandType.StoredProcedure); // Wrapped Dapper db.DapperProcNonQuery("CreateNewCustomer", new { Name = "dappernametoolongtowork", TotalPurchases = 12000, TotalReturns = 100.50M }); } catch (Exception ex) { var efd = GetFlogDetail("", ex); Flogger.WriteError(efd); } } var ctx = new CustomerDbContext(); try { // Entity Framework var name = new SqlParameter("@Name", "waytoolongforitsowngood"); var totalPurchases = new SqlParameter("@TotalPurchases", 12000); var totalReturns = new SqlParameter("@TotalReturns", 100.50M); ctx.Database.ExecuteSqlCommand("EXEC dbo.CreateNewCustomer @Name, @TotalPurchases, @TotalReturns", name, totalPurchases, totalReturns); } catch (Exception ex) { var efd = GetFlogDetail("", ex); Flogger.WriteError(efd); } var customers = ctx.Customers.ToList(); fd = GetFlogDetail($"{customers.Count} customers in the database", null); Flogger.WriteDiagnostic(fd); fd = GetFlogDetail("used flogging console", null); Flogger.WriteUsage(fd); fd = GetFlogDetail("stopping app", null); Flogger.WriteDiagnostic(fd); tracker.Stop(); }