Ejemplo n.º 1
0
        public void Log(string message, Category category, Priority priority)
        {
            lock (this)
            {
                Trace.WriteLine(message, category.ToString());
                var data = new LogMessage();
                data.Message = message;
                data.Category = category;
                data.Priority = priority;

                try
                {
                    if (!container.IsRegistered<LogViewer>()) throw new NotImplementedException();

                    var aggregator = container.Resolve<IEventAggregator>();
                    while (failedMessages.Any())
                    {
                        var item = failedMessages.Dequeue();
                        aggregator.GetEvent<LogEvent>().Publish(item);
                    }
                    aggregator.GetEvent<LogEvent>().Publish(data);
                }
                catch (Exception)
                {
                    failedMessages.Enqueue(data);
                }
            }
        }
Ejemplo n.º 2
0
        private void OnLogEvent(LogMessage item)
        {
            if (item.Category == Category.Debug) return;

            var text = item.Message;
            if (string.IsNullOrEmpty(LogText))
            {
                LogText = text;
            }
            else
            {
                LogText += Environment.NewLine + text;
            }

            view.ScrollDown();
        }