public void Add(NetStashEvent log) { Entities.Log addLog = new Entities.Log(); //addLog.Message = Newtonsoft.Json.JsonConvert.SerializeObject(log); //Microsoft.AspNetCore.Formatter.Json string JsonString = log.GetJson(); addLog.Message = JsonString; using (IDbConnection db = NetStashStandard.Log.NetStashLog.TypeNet == Log.TypeNet.NetCore ? baseProxy.GetConnectionSqlite() : baseProxy.GetConnection()) using (IDbCommand cmd = db.CreateCommand()) { cmd.CommandText = "INSERT INTO Log (Message) VALUES (@Message)"; cmd.CommandType = CommandType.Text; IDbDataParameter pMessage = cmd.CreateParameter(); pMessage.ParameterName = "@Message"; pMessage.Value = addLog.Message; cmd.Parameters.Add(pMessage); cmd.Prepare(); db.Open(); cmd.ExecuteNonQuery(); } }
public void Fatal(string message, System.Reflection.MethodBase currentMethod, string OldValue = "", string NewValue = "") { NetStashEvent netStashEvent = new NetStashEvent(); netStashEvent.Level = NetStashLogLevel.Fatal.ToString(); netStashEvent.Message = message; netStashEvent.Method = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; netStashEvent.Fields = GetFields(OldValue, NewValue); this.AddSendToLogstash(netStashEvent); }
public void Debug(string message, Dictionary <string, string> values = null) { NetStashEvent netStashEvent = new NetStashEvent(); netStashEvent.Level = NetStashLogLevel.Debug.ToString(); netStashEvent.Message = message; netStashEvent.Fields = values; this.AddSendToLogstash(netStashEvent); }
internal void InternalError(string message, Dictionary <string, string> values = null) { NetStashEvent netStashEvent = new NetStashEvent(); netStashEvent.Level = NetStashLogLevel.Error.ToString(); netStashEvent.Message = message; netStashEvent.Fields = values; this.AddSendToLogstash(netStashEvent, false); }
public void Error(Exception exception, Dictionary <string, string> values) { NetStashEvent netStashEvent = new NetStashEvent(); netStashEvent.Level = NetStashLogLevel.Error.ToString(); netStashEvent.Message = exception.Message; netStashEvent.ExceptionDetails = exception.StackTrace; netStashEvent.Fields = values; this.AddSendToLogstash(netStashEvent); }
public void Error(Exception exception, System.Reflection.MethodBase currentMethod, string OldValue = "", string NewValue = "") { NetStashEvent netStashEvent = new NetStashEvent(); netStashEvent.Level = NetStashLogLevel.Error.ToString(); netStashEvent.Message = exception.Message; netStashEvent.ExceptionDetails = exception.StackTrace; netStashEvent.Method = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; netStashEvent.Fields = GetFields(OldValue, NewValue); this.AddSendToLogstash(netStashEvent); }
private void AddSendToLogstash(NetStashEvent e, bool run = true) { e.Machine = Environment.MachineName; e.Source = system; e.Index = logname; Storage.Proxy.LogProxy proxy = new Storage.Proxy.LogProxy(); proxy.Add(e); if (run) { Worker.TcpWorker.Run(); } }
/// <summary> /// Registra um novo evento de log /// </summary> /// <param name="level">Nivel do log</param> /// <param name="message">Mensagem descritiva do log</param> /// <param name="exception">Exceçao que sera logado</param> /// <param name="addtionalValues">Valores adicionais que serao incluidos no log</param> public void Log(NetStashLogLevel level, string message, Exception exception, Dictionary <string, string> addtionalValues) { var netStashEvent = new NetStashEvent { Level = level.ToString(), Message = message, ExceptionMessage = exception?.Message, ExceptionDetails = exception?.StackTrace, Fields = addtionalValues }; AddSendToLogstash(netStashEvent); }
private void AddSendToLogstash(NetStashEvent e, bool run = true) { e.Machine = Environment.MachineName; e.MacAddress = (from nic in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() where nic.OperationalStatus == System.Net.NetworkInformation.OperationalStatus.Up select nic.GetPhysicalAddress().ToString()).FirstOrDefault(); e.AppVersion = currentAppVersion; e.Username = user; Storage.Proxy.LogProxy proxy = new Storage.Proxy.LogProxy(); proxy.Add(e); if (run) { Worker.TcpWorker.Run(); } }
/// <summary> /// Adiciona uma nova mensagem no banco de dados /// </summary> /// <param name="log">Evento que sera adicionado</param> public void Add(NetStashEvent log) { Entities.Log addLog = new Entities.Log(); addLog.Message = Newtonsoft.Json.JsonConvert.SerializeObject(log.ToDictionary()); using (IDbConnection db = base.GetConnection()) using (IDbCommand cmd = db.CreateCommand()) { cmd.CommandText = "INSERT INTO Log (Message) VALUES (@Message)"; cmd.CommandType = CommandType.Text; IDbDataParameter pMessage = cmd.CreateParameter(); pMessage.ParameterName = "@Message"; pMessage.Value = addLog.Message; cmd.Parameters.Add(pMessage); db.Open(); cmd.Prepare(); cmd.ExecuteNonQuery(); } }
public void Information(string message, System.Reflection.MethodBase currentMethod, string OldValue = "", string NewValue = "") { NetStashEvent netStashEvent = new NetStashEvent(); netStashEvent.Level = NetStashLogLevel.Information.ToString(); netStashEvent.Message = message; netStashEvent.Method = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; Dictionary <string, string> Fields = new Dictionary <string, string>(); if (OldValue.Length > 0) { Fields.Add("OldValue", OldValue); } if (NewValue.Length > 0) { Fields.Add("NewValue", NewValue); } netStashEvent.Fields = Fields; this.AddSendToLogstash(netStashEvent); }
public void Error(Exception exception, System.Reflection.MethodBase currentMethod, string OldValue = "", string NewValue = "") { NetStashEvent netStashEvent = new NetStashEvent(); netStashEvent.Level = NetStashLogLevel.Error.ToString(); netStashEvent.Message = exception.Message; netStashEvent.ExceptionDetails = exception.StackTrace; netStashEvent.Method = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; Dictionary <string, string> Fields = new Dictionary <string, string>(); if (OldValue.Length > 0) { Fields.Add("OldValue", OldValue); } if (NewValue.Length > 0) { Fields.Add("NewValue", NewValue); } netStashEvent.Fields = Fields; this.AddSendToLogstash(netStashEvent); }