Пример #1
0
        public void Write(LoggerItem item)
        {
            //remove the BELL symbol (according to ASCII) to stop the Windows console
            //triggers beeps when displaying binary data

            String message = item.Message.Replace('\x7', ' ');

            Console.WriteLine("{0}:{1}", item.Date, message);
        }
Пример #2
0
        public void Show(LogLevel level, string format, params object[] args)
        {
            if (CheckLevel(level))
            {
                LoggerItem item = new LoggerItem(level)
                {
                    Modal    = true,
                    Message  = String.Format(format, args),
                    Category = this.Category
                };

                Writer.Write(item);
            }
        }
Пример #3
0
        public void Write(LoggerItem item)
        {
            ILogWriter[] writers;

            lock (this)
            {
                writers = Writers.ToArray();
            }

            foreach (ILogWriter writer in writers)
            {
                writer.Write(item);
            }
        }
Пример #4
0
        public void Write(LoggerItem item)
        {
            if (this.Dispatcher.CheckAccess())
            {
                // The calling thread owns the dispatcher, and hence the UI element

                AddLoggerItem(item);
            }
            else
            {
                //invocation required
                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                            new LoggerItemDelegate(AddLoggerItem), item);
            }
        }
Пример #5
0
        void ReportException(string message, Exception x, bool modal)
        {
            LoggerItem item = new LoggerItem(LogLevel.Error)
            {
                Modal = modal,

                Message = message,

                Category = this.Category,

                Details = Format.GetExceptionMessage(x)
            };

            Writer.Write(item);
        }
Пример #6
0
        public void Print(LogLevel level, string format, params object[] args)
        {
            if (CheckLevel(level))
            {
                LoggerItem item = new LoggerItem(level)
                {
                    Message  = String.Format(format, args),
                    Category = this.Category
                };

                //System.Diagnostics.Debug.Print(item.Message);

                Writer.Write(item);
            }
        }
Пример #7
0
        void AddLoggerItem(LoggerItem item)
        {
            if (loggerItems.Count > LogLimit)
            {
                //loggerItems.RemoveAt(loggerItems.Count - 1);

                int tail_len = loggerItems.Count - LogLimit;

                for (int i = 0; i < tail_len; ++i)
                {
                    loggerItems.RemoveAt(LogLimit);
                }
            }

            loggerItems.Insert(0, item);

            if (item.Modal)
            {
                ShowMessage(item);
            }
        }
Пример #8
0
 public void Write(LoggerItem item)
 {
     //it does nothing
 }