Exemple #1
0
 /// <summary>
 /// This method will collect data and call the trigger of event
 /// </summary>
 /// <param name="Severity">Severity of message</param>
 /// <param name="TextFormat">text format</param>
 /// <param name="param">variable value in text format</param>
 protected void Logging(DebugSeverityTypes Severity, string TextFormat, params object[] param)
 {
     if (dlgtLogSend != null)
     {
         string           strText = string.Format(TextFormat, param);
         LogSendEventArgs e       = new LogSendEventArgs(strText,
                                                         DateTime.Now,
                                                         Severity,
                                                         tmName);
         dlgtLogSend(this, e);
     }
 }
Exemple #2
0
        public void OnLogReceived(object sender, LogSendEventArgs e)
        {
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //Absolutly not logging itself!!!!!!
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //Absolutly not logging itself!!!!!!
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //Absolutly not logging itself!!!!!!
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //log example:
            //[20200413_144559.234]:    [error] [session] [text]
            try
            {
                if (Array.IndexOf(CheckedSeverity, Convert.ToInt32(e.Severity)) == -1)
                {
                    //The debug msg is not required in initial settings.
                    return;
                }
                string strSeverity = string.Empty;
                switch (e.Severity)
                {
                case DebugSeverityTypes.Unknown: strSeverity = "Unknown\t";
                    break;

                case DebugSeverityTypes.Info: strSeverity = "Info\t\t";
                    break;

                case DebugSeverityTypes.Warning: strSeverity = "Warn\t\t";
                    break;

                case DebugSeverityTypes.Important: strSeverity = "Important\t";
                    break;

                case DebugSeverityTypes.Fatal: strSeverity = "Fatal\t\t";
                    break;
                }

                string Text = string.Format("[{0}]:\t[{1}][{2}]\t\t{3}",
                                            e.TimeStamp.ToString(CommonTags.Common_LongDateTime),
                                            strSeverity,
                                            e.SessionName,
                                            e.Text);
                AppendLine(Text);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("{0}->{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, ex.Message));
            }
        }