Esempio n. 1
0
 /// <summary>
 /// Log with an entry and only text
 /// </summary>
 /// <param name="entryType">The type to log</param>
 /// <param name="sourceName">The name of the source of the log</param>
 /// <param name="sourceGuid">The guid of the source of the log</param>
 /// <param name="text">The text string</param>
 public void Log(LogEntryType entryType, string sourceName, Guid sourceGuid, string text)
 {
     if ((LogEntryAdded != null) && (text != null))
     {
         if ((LogLevel & entryType) == entryType)
         {
             LogEntryAdded.Invoke(this, new LogEntryAddedEventArgs(entryType, text, null, sourceName ?? "Unknown", sourceGuid));
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Log a formatted entry
 /// </summary>
 /// <param name="entryType">The type to log</param>
 /// <param name="sourceName">The name of the source of the log</param>
 /// <param name="sourceGuid">The guid of the source of the log</param>
 /// <param name="format">The format string</param>
 /// <param name="args">Format arguments</param>
 public void Log(LogEntryType entryType, string sourceName, Guid sourceGuid, string format, params object[] args)
 {
     if (LogEntryAdded != null)
     {
         if ((LogLevel & entryType) == entryType)
         {
             LogEntryAdded.Invoke(this, new LogEntryAddedEventArgs(entryType, String.Format(format, args), null, sourceName, sourceGuid));
         }
     }
 }
Esempio n. 3
0
        public override void WriteLine(string message)
        {
            var logEntry = new LogEntry()
            {
                Source    = _name,
                Severity  = _severity,
                Text      = _lineBuffer + message,
                TimeStamp = DateTime.Now
            };

            _lineBuffer = null;

            LogEntryAdded?.Invoke(logEntry);
        }
Esempio n. 4
0
        /// <summary>
        /// Log an exception
        /// </summary>
        /// <param name="type">Type of log entry</param>
        /// <param name="sourceGuid">Guid of the source</param>
        /// <param name="sourceName">Name of the source</param>
        /// <param name="ex">The exception to log</param>
        public void LogException(LogEntryType type, string sourceName, Guid sourceGuid, Exception ex)
        {
            if (LogEntryAdded != null)
            {
                if ((LogLevel & type) == type)
                {
                    string message = ex.Message;

                    // Unwrap a few common wrapped messages
                    if ((ex is TargetInvocationException) || (ex is AuthenticationException))
                    {
                        if (ex.InnerException != null)
                        {
                            message = ex.InnerException.Message;
                        }
                    }

                    LogEntryAdded.Invoke(this, new LogEntryAddedEventArgs(type, message, ex, sourceName, sourceGuid));
                }
            }
        }
Esempio n. 5
0
 protected static void OnLogEntryAdded(string logEntry) => LogEntryAdded?.Invoke(null, logEntry);
Esempio n. 6
0
 private void OnLogEntryAdded(LogEntry entry)
 {
     LogEntryAdded?.Invoke(this, new LogEntryAddedEventArgs(entry));
 }
Esempio n. 7
0
 public void Report(LogEntry entry)
 {
     _logger.Log(entry);
     LogEntryAdded?.Invoke(this, new LogEntryAddedEventArgs(entry));
 }
Esempio n. 8
0
 public static void Log(LogEntry entry)
 {
     LogEntryAdded?.Invoke(entry);
     entries.Add(entry);
 }
Esempio n. 9
0
 /// <summary>
 /// Invoke the LogEntryAdded event
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnLogEntryAdded(LogEntryAddedEventArgs e)
 {
     LogEntryAdded?.Invoke(null, e);
 }