Пример #1
0
 public HistoLigne(IDRobot robot, DateTime heure, String message, TypeLog type = TypeLog.Strat)
 {
     ID = idActuel++;
     Robot = robot;
     Message = message;
     Heure = heure;
     Type = type;
 }
Пример #2
0
 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);
 }
Пример #3
0
        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();
        }
Пример #4
0
        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);
                }
            }
        }
Пример #5
0
 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
     {
     }
 }
Пример #6
0
        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)));
        }
Пример #7
0
 protected abstract void Execute(TypeLog typeLog, T message, Exception exception);
Пример #8
0
 public static void Release(string msg, string jsonXml, Exception ex = null, TypeLog typeLog = TypeLog.Information)
 {
     Release(msg, ex, GetObject(jsonXml), typeLog);
 }
Пример #9
0
        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)
            { }
        }
Пример #10
0
 public bool WriteEvent(string title, string message, TypeLog typeLog = TypeLog.Info, bool noDialog = false)
 {
     throw new NotImplementedException();
 }
Пример #11
0
 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);
 }
Пример #12
0
 public ProcessorEntryLog(string text, TypeLog typeLog)
 {
     Text    = text;
     TypeLog = typeLog;
 }
Пример #13
0
 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);
 }
Пример #14
0
 public static void WriteLog(Exception ex, TypeLog type = TypeLog.Error)
 {
     WriteActualLog(String.Format("Error[{0}]: {1}", ex.HResult, ex.Message), type);
 }
Пример #15
0
 public static void WriteLog(string message, TypeLog type = TypeLog.Information)
 {
     WriteActualLog(message, type);
 }
Пример #16
0
 /// <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);
 }
Пример #17
0
 /// <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);
 }
Пример #18
0
 public Logger(TypeLog typelog)
 {
     _typelog = typelog;
 }
Пример #19
0
 public void LogMessage(string message, TypeLog type)
 {
     Console.ForegroundColor = GetColor(type);
     Console.WriteLine(DateTime.Now.ToShortDateString().Replace("/", "-") + message);
     Console.Read();
 }
Пример #20
0
 public static void Log(string s, TypeLog typeLog = TypeLog.Normal)
 {
     Instance.ProcessLog(s, typeLog);
 }
Пример #21
0
 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);
     }
 }
Пример #22
0
 public FarmAnimal(long id, TypeLog typeLog)
 {
     Id      = id;
     TypeLog = typeLog;
 }
Пример #23
0
        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());
        }
Пример #24
0
 public static void Release(string msg, string jsonXml, Exception ex = null, TypeLog typeLog = TypeLog.Information)
 {
     Release(msg, ex, GetObject(jsonXml), typeLog);
 }
Пример #25
0
 public LoggerArgs(string text, TypeLog typeLog)
 {
     Text    = text;
     TypeLog = typeLog;
 }