예제 #1
0
        Dictionary <string, IJFLogger> _stationLoggers = new Dictionary <string, IJFLogger>(); //各工站的日志记录对象

        /// <summary>
        /// 接收一条工站日志记录,保存
        /// 如果工站自身未提供UI,则会在架构附加的StationUI上显示
        /// 如果工站自身有UI,则忽略显示功能
        /// </summary>
        /// <param name="info"></param>
        public void OnStationLog(IJFStation station, string info, JFLogLevel level, LogMode mode)
        {
            ///添加界面显示
            ///向日志线程中添加一条记录

            if (null == station)
            {
                throw new ArgumentNullException("Station is null in JFStationManeger.StationLog(station, ...");
            }
            string stationName = station.Name;

            if (string.IsNullOrEmpty(stationName))
            {
                throw new ArgumentNullException("Station's Name is null or empty in JFStationManeger.StationLog(station, ...");
            }

            if ((mode & LogMode.Record) == LogMode.Record)
            {
                if (!_stationLoggers.ContainsKey(stationName))
                {
                    _stationLoggers.Add(stationName, JFLoggerManager.Instance.GetLogger(stationName));
                }
                _stationLoggers[stationName].Log(level, info);
            }
            if (_isShowLogThreadRunning)
            {
                if ((mode & LogMode.Show) == LogMode.Show)
                {
                    if (_StationMsgReciever.ContainsKey(station))
                    {
                        _log2Shows.Enqueue(new KeyValuePair <IJFStation, string>(station, level.ToString() + ":" + info));
                        _semaphoreShowLog.Release(1);
                    }
                }
            }
        }
예제 #2
0
 public LogRecord(DateTime time, JFLogLevel level, string info)
 {
     Time  = time;
     Level = level;
     Info  = info;
 }