public void WriteLog(LogEntry logEntry)
 {
     App.Current.RootVisual.Dispatcher.BeginInvoke(() =>
                 
                     System.Windows.Browser.HtmlPage.Window.Alert(
                         logEntry.Message)
                 );
 }
Exemplo n.º 2
0
 public void WriteLog(LogEntry logEntry)
 {
     try
     {
         Trace.WriteLine(string.Format("Severity: \"{0}\" Sender: \"{1}\" Message: \"{2}\" Timestamp: \"{3}\"", new object[] { logEntry.Severity, logEntry.SenderName, logEntry.Message, logEntry.Timestamp }));
         if (this.LogWriteSuccessful != null)
         {
             this.LogWriteSuccessful(this, logEntry);
         }
     }
     catch (Exception exception)
     {
         if (this.LogWriteFailed != null)
         {
             this.LogWriteFailed(this, logEntry, exception);
         }
     }
 }
        /// <summary>
        /// Writes a specified LogEntry to the LogWriter.
        /// </summary>
        /// <param name="logEntry">The LogEntry to write.</param>
        public void WriteLog(LogEntry logEntry)
        {
            try
            {
                string message = string.Format(PluginsResources.DebugLogWriterOutputFormat, logEntry.Severity,
                                               logEntry.SenderName, logEntry.Message, logEntry.Timestamp);
                Debug.WriteLine(message);

                if (LogWriteSuccessful != null)
                {
                    LogWriteSuccessful(this, logEntry);
                }
            }
            catch (Exception err)
            {
                if (LogWriteFailed != null)
                {
                    LogWriteFailed(this, logEntry, err);
                }
            }
        }
 private void WriteLog(ILogWriter logWriter, LogEntry logEntry)
 {
     try
     {
         logWriter.WriteLog(logEntry);
     }
     catch (Exception err)
     {
         LogWriteErrorOccurred.IfNotNull(i => i(logWriter, logEntry, err));
     }
 }
 /// <summary>
 /// Writes a log entry to each of the LogWriters.
 /// </summary>
 /// <param name="logEntry">The log entry to write.</param>
 public void SendLogEntry(LogEntry logEntry)
 {
     if (LogWriters != null)
     {
         LogWriters.Where(i => i.IsLoaded)
             .ForEach(i => WriteLog(i, logEntry));
     }
 }
 private void LogWriter_LogWriteErrorOccurred(ILogWriter logWriter, LogEntry logEntry, Exception err)
 {
     LogWriteErrorOccurred.IfNotNull(i => i(logWriter, logEntry, err));
 }
 private void LogWriter_LogWriteSuccessful(ILogWriter logWriter, LogEntry logEntry)
 {
     LogWriteSuccessful.IfNotNull(i => i(logWriter, logEntry));
 }
Exemplo n.º 8
0
        protected void SendLogEntry(string type,
                                  Microsoft.SilverlightMediaFramework.Plugins.Primitives.LogLevel severity = Microsoft.SilverlightMediaFramework.Plugins.Primitives.LogLevel.Information,
                                  string message = null,
                                  DateTime? timeStamp = null,
                                  IEnumerable<KeyValuePair<string, object>> extendedProperties = null)
        {
            if (LogReady != null)
            {
                var logEntry = new LogEntry
                {
                    Severity = severity,
                    Message = message,
                    SenderName = PluginName,
                    Timestamp = timeStamp.HasValue ? timeStamp.Value : DateTime.Now
                };

                extendedProperties.ForEach(logEntry.ExtendedProperties.Add);
                LogReady(this, logEntry);
            }
        }
        private void SendLogEntry(string type,
                                  LogLevel severity = LogLevel.Information,
                                  string message = null,
                                  DateTime? timeStamp = null,
                                  IEnumerable<KeyValuePair<string, object>> extendedProperties = null)
        {
            if (LogReady != null)
            {
                var logEntry = new LogEntry
                                   {
                                       Severity = severity,
                                       Message = message,
                                       SenderName = PluginName,
                                       Timestamp = timeStamp.HasValue ? timeStamp.Value : DateTime.Now
                                   };

                extendedProperties.ForEach(logEntry.ExtendedProperties.Add);
                LogReady(this, logEntry);
            }
        }
 private void Logger_LogWriteSuccessful(ILogWriter logWriter, LogEntry logEntry)
 {
     LogWriteSuccessful.IfNotNull(i => i(this, new CustomEventArgs<LogEntry>(logEntry)));
 }
 private void Logger_LogWriteErrorOccurred(ILogWriter logWriter, LogEntry logEntry, Exception err)
 {
     LogWriteErrorOccurred.IfNotNull(i => i(this, new LogWriteErrorOccurredInfo { LogEntry = logEntry, Error = err }));
 }
 private void Plugin_LogReady(IPlugin plugin, LogEntry logEntry)
 {
     Dispatcher.BeginInvoke(() => OnPluginLogReady(plugin, logEntry));
 }
 protected virtual void OnPluginLogReady(IPlugin plugin, LogEntry logEntry)
 {
     if ((logEntry.Severity & LogLevel) != LogLevel.None)
     {
         OnLogEntryReceived(logEntry);
     }
 }
        /// <summary>
        ///
        /// </summary>
        protected virtual void OnLogEntryReceived(LogEntry logEntry)
        {
            LogEntryReceived.IfNotNull(i => i(this, new CustomEventArgs<LogEntry>(logEntry)));
            _logger.SendLogEntry(logEntry);

            if (LoggingDisplayElement != null)
            {
                string output = string.Format(SilverlightMediaFrameworkResources.LoggingOutputFormat, logEntry.Severity,
                                              logEntry.SenderName, logEntry.Type, logEntry.Message, logEntry.Timestamp);
                LoggingDisplayElement.Text = output + Environment.NewLine + LoggingDisplayElement.Text;
            }
        }
        internal void SendLogEntry(string type,
                                  LogLevel severity = LogLevel.Information,
                                  string message = null,
                                  string senderName = null,
                                  DateTime? timeStamp = null,
                                  IEnumerable<KeyValuePair<string, object>> extendedProperties = null)
        {
            if ((severity & LogLevel) != LogLevel.None)
            {
                var logEntry = new LogEntry
                                   {
                                       Severity = severity,
                                       Message = message ?? string.Empty,
                                       Type = type ?? KnownLogEntryTypes.GeneralLogEntry,
                                       SenderName = !string.IsNullOrEmpty(senderName) ? senderName : "Player",
                                       Timestamp = timeStamp.HasValue ? timeStamp.Value : DateTime.Now
                                   };

                extendedProperties.ForEach(logEntry.ExtendedProperties.Add);

                OnLogEntryReceived(logEntry);
            }
        }
Exemplo n.º 16
0
 void ReportIfError(Action action)
 {
     try
     {
         action();
     }
     catch (Exception ex)
     {
         var log = new LogEntry();
         log.Severity = LogLevel.Warning;
         log.Type = "ThumbnailPlugin";
         log.Message = ex.Message;
         LogReady.IfNotNull(l => l(this, log));
     }
 }