示例#1
0
        /// <summary>
        /// Logs the value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="typeLog">The type log.</param>
        public void LogValue(string value, ETypeLog typeLog, string specFileName)
        {
            if (Logger == null)
            {
                Logger = new TDevSrvLogger();
            }

            try
            {
                DateTime now       = DateTime.Now;
                string   valueTime = "{0} {1} [" + value + "]";
                string   time      = string.Format("[{0}/{1}/{2} {3}:{4}:{5}:{6}]",
                                                   now.Year.ToString("0000"),       //{0}
                                                   now.Month.ToString("00"),        //{1}
                                                   now.Day.ToString("00"),          //{2}
                                                   now.Hour.ToString("00"),         //{3}
                                                   now.Minute.ToString("00"),       //{4}
                                                   now.Second.ToString("00"),       //{5}
                                                   now.Millisecond.ToString("00")); //{6}

                string prefix = "";
                string str    = string.Format(valueTime, time, prefix);

                switch (typeLog)
                {
                case ETypeLog.External:
                    LogValueTo(str, specFileName);
                    break;

                case ETypeLog.OPC:
                    LogValueTo(str, specFileName);
                    break;

                case ETypeLog.Crit:
                    Logger.Warn(str);
                    break;

                case ETypeLog.Out:
                    Logger.Info(str);
                    break;

                case ETypeLog.Serv:
                    Logger.Debug(valueTime, time, prefix);
                    break;

                default:
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#2
0
文件: Example2.cs 项目: kri1sv/pdc
        /// <summary>
        /// Logs the value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="typeLog">The type log.</param>
        public void LogValue(string value, ETypeLog typeLog, string specFileName)
        {
            if (Logger == null)
            {
                Logger = new TDevSrvLogger();
            }

            try
            {
                DateTime now = DateTime.Now;
                string valueTime = "{0} {1} [" + value + "]";
                string time = string.Format("[{0}/{1}/{2} {3}:{4}:{5}:{6}]",
                    now.Year.ToString("0000"),              //{0}
                    now.Month.ToString("00"),               //{1}
                    now.Day.ToString("00"),                 //{2}
                    now.Hour.ToString("00"),                //{3}
                    now.Minute.ToString("00"),              //{4}
                    now.Second.ToString("00"),              //{5}
                    now.Millisecond.ToString("00"));        //{6}

                string prefix = "";
                string str = string.Format(valueTime, time, prefix);

                switch (typeLog)
                {
                    case ETypeLog.External:
                        LogValueTo(str, specFileName);
                        break;
                    case ETypeLog.OPC:
                        LogValueTo(str, specFileName);
                        break;
                    case ETypeLog.Crit:
                        Logger.Warn(str);
                        break;
                    case ETypeLog.Out:
                        Logger.Info(str);
                        break;
                    case ETypeLog.Serv:
                        Logger.Debug(valueTime, time, prefix);
                        break;
                    default:
                        break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#3
0
文件: Example2.cs 项目: kri1sv/pdc
 public void LogValue(string value, ETypeLog typeLog)
 {
     LogValue(value, typeLog, "");
 }
示例#4
0
 public void LogValue(string value, ETypeLog typeLog)
 {
     LogValue(value, typeLog, "");
 }