public HistoLigne(IDRobot robot, DateTime heure, String message, TypeLog type = TypeLog.Strat) { ID = idActuel++; Robot = robot; Message = message; Heure = heure; Type = type; }
public static void Debug(string msg, Exception ex = null, object obj = null, TypeLog typeLog = TypeLog.Information) { if (ex != null) { typeLog = TypeLog.Error; } if (Params.ApplicationMode == ApplicationMode.Debug) SaveMessage(msg, ex, obj, typeLog); }
protected override void Execute(TypeLog typeLog, string messageLog, Exception exception) { var command = new SqlCommand(_query, _conection.Value); var message = new SqlParameter("@message", SqlDbType.NVarChar) { Value = (object)messageLog ?? DBNull.Value }; IncludeException(command, exception); var httpMethod = new SqlParameter("@httpMethod", SqlDbType.NVarChar) { Value = (object)HttpMethod ?? DBNull.Value }; var path = new SqlParameter("@path", SqlDbType.NVarChar) { Value = (object)Path ?? DBNull.Value }; var urlReferrer = new SqlParameter("@urlReferrer", SqlDbType.NVarChar) { Value = (object)UrlReferrer ?? DBNull.Value }; var userAgent = new SqlParameter("@userAgent", SqlDbType.NVarChar) { Value = (object)UserAgent ?? DBNull.Value }; var isAuthenticated = new SqlParameter("@isAuthenticated", SqlDbType.Bit) { Value = IsAuthenticated }; var type = new SqlParameter("@type", SqlDbType.TinyInt) { Value = (int)typeLog }; command.Parameters.AddRange(new[] { message, httpMethod, path, urlReferrer, userAgent, isAuthenticated, type }); command.ExecuteNonQuery(); }
public void LogMessage(string message, TypeLog type) { if (!this.IsMessageValid(message)) { return; } if (CompareConfigurationWithType(type)) { if (ConfigurationLogEntity.LogToDataBase) { LoggerInDataBase.LogMessage(message, type); } if (ConfigurationLogEntity.LogToFile) { LoggerInFile.LogMessage(message, type); } if (ConfigurationLogEntity.LogToConsole) { LoggerInConsole.LogMessage(message, type); } } }
public void WriteLog(string Caller, string Method, TypeLog Type, Exception ex) { try { using (StreamWriter w = File.AppendText(fileName)) { w.WriteLine("--------------------------------------------------------------------------------"); w.WriteLine("DateTime: " + DateTime.Now.ToString()); w.WriteLine("Type: " + Type.ToString()); w.WriteLine("Caller: " + Caller); w.WriteLine("Method: " + Method); w.WriteLine("Message: " + ex.Message); w.WriteLine("Source: " + ex.Source); w.WriteLine("TargetSite: " + ex.TargetSite); w.WriteLine("StackTrace: " + ex.StackTrace); w.WriteLine("InnerException: " + ex.InnerException); w.WriteLine("--------------------------------------------------------------------------------"); } } catch { } }
public override string ToString() { return(string.Format(@" {0}|{1}:{2} Exception: {3}, Stacktrace: {4}, Domain: {5}, Username: {6}, Hostname: {7}, Ips: {8}, Class: {9}, Method: {10}, Line: {11}, IdTypeObject: {12}, IdObject: {13}, ApplicationMode: {14}, Thread: {15} {16} ", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), Enum.GetName(TypeLog.GetType(), TypeLog), Msg, Exception, Stacktrace, Domain, Username, Hostname, Ips, Class, Method, Line, IdTypeObject, IdObject, Enum.GetName(ApplicationMode.GetType(), ApplicationMode), Thread, new String('-', 5))); }
protected abstract void Execute(TypeLog typeLog, T message, Exception exception);
public static void Release(string msg, string jsonXml, Exception ex = null, TypeLog typeLog = TypeLog.Information) { Release(msg, ex, GetObject(jsonXml), typeLog); }
public static void SaveMessage(string msg, Exception ex, object obj, TypeLog type) { try { Message message = new Message(); message.Msg = msg; if (ex != null) { message.Exception = ex.ToString(); } message.TypeLog = type; StackTrace stack = new StackTrace(); var frames = stack.GetFrames(); foreach (var item in frames) { if (!(item.GetMethod().DeclaringType.Name == "Log" && item.GetMethod().DeclaringType.Namespace == "Logger")) { message.Method = item.GetMethod().ToString(); message.Class = item.GetMethod().DeclaringType.Name; message.Line = item.GetFileLineNumber(); break; } } if ((Params.OutputLog & OutputLog.Text) == OutputLog.Text) { SaveMessageText(message); } if ((Params.OutputLog & OutputLog.SQLite) == OutputLog.SQLite) { int idtTypeObj = 0; int idObj = 0; if (obj != null) { Type typeObj = obj.GetType(); Hashtable colluns; if (obj.GetType() == typeof(Hashtable)) { colluns = (Hashtable)obj; } else { colluns = SerializeObject(obj); } idObj = business.InsertObject(typeObj.Name, colluns, out idtTypeObj); } int idAppliction = business.InsertApplication(); message.IdApplication = idAppliction; message.IdObject = idObj; message.IdTypeObject = idtTypeObj; business.InsertMessage(message); } } catch (Exception exception) { } }
public bool WriteEvent(string title, string message, TypeLog typeLog = TypeLog.Info, bool noDialog = false) { throw new NotImplementedException(); }
public static void Log(string s, object arg0, object arg1, object arg2, TypeLog typeLog = TypeLog.Normal) { Instance.ProcessLog(string.Format(s, arg0, arg1, arg2), typeLog); }
public ProcessorEntryLog(string text, TypeLog typeLog) { Text = text; TypeLog = typeLog; }
public void Log(String message, TypeLog type = TypeLog.Strat) { HistoLigne ligne = new HistoLigne(Robot, DateTime.Now, message, type); HistoriqueLignes.Add(ligne); if (NouveauLog != null) NouveauLog(ligne); }
public static void WriteLog(Exception ex, TypeLog type = TypeLog.Error) { WriteActualLog(String.Format("Error[{0}]: {1}", ex.HResult, ex.Message), type); }
public static void WriteLog(string message, TypeLog type = TypeLog.Information) { WriteActualLog(message, type); }
/// <summary> /// Records the trace. /// </summary> /// <param name="message">Message.</param> /// <param name="type">Type.</param> /// <param name="policy">Policy.</param> public static void RecordTrace(string message, TypeLog type, Pilicy policy) { InsertLog(message, type, policy); }
/// <summary> /// Records the log. /// </summary> /// <param name="ex">Exeption.</param> /// <param name="type">Type of record.</param> /// <param name="policy">Policy.</param> public static void RecordLog(Exception ex, TypeLog type, Pilicy policy) { InsertLog($"Message: {ex.Message} - Trace: {ex.StackTrace}", type, policy); }
public Logger(TypeLog typelog) { _typelog = typelog; }
public void LogMessage(string message, TypeLog type) { Console.ForegroundColor = GetColor(type); Console.WriteLine(DateTime.Now.ToShortDateString().Replace("/", "-") + message); Console.Read(); }
public static void Log(string s, TypeLog typeLog = TypeLog.Normal) { Instance.ProcessLog(s, typeLog); }
public static void Release(string msg, Exception ex = null, object obj = null, TypeLog typeLog = TypeLog.Information) { if (ex != null) { typeLog = TypeLog.Error; } if (Params.ApplicationMode == ApplicationMode.Release) { SaveMessage(msg, ex, obj, typeLog); } }
public FarmAnimal(long id, TypeLog typeLog) { Id = id; TypeLog = typeLog; }
private void VerifyDontCall(ConfigurationLogEntity configuration, string message, TypeLog type) { //Arrange JobLoggerRefactored log = new JobLoggerRefactored(configuration, this.loggerDataBase.Object, this.loggerFile.Object, this.loggerConsole.Object); //Act log.LogMessage(message, type); //Assert this.loggerFile.Verify(v => v.LogMessage(message, type), Times.Never()); }
public LoggerArgs(string text, TypeLog typeLog) { Text = text; TypeLog = typeLog; }