コード例 #1
0
        /// <summary>
        ///     Enqueues the supplied <see cref="RealtimeLoggerEventArgs"/> instance to the LogHistory queue. If the queue exceeds
        ///     200 entries, the oldest log is first de-queued before the new log is enqueued.
        /// </summary>
        /// <param name="eventArgs">The event args instance to enqueue.</param>
        private static void AppendLogHistory(RealtimeLoggerEventArgs eventArgs)
        {
            LogHistory.Enqueue(eventArgs);

            if (LogHistory.Count > LogHistoryLimit)
            {
                PruneLogHistory();
            }
        }
コード例 #2
0
 /// <summary>
 ///     Fired when the <see cref="RealtimeLogger"/>  receives a new log message.
 /// </summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void AppendLog(object sender, RealtimeLoggerEventArgs e)
 {
     // threadsafe
     this.Invoke((MethodInvoker) delegate
     {
         string msg    = e.DateTime + " | " + e.Message;
         txtLogs.Text += msg + Environment.NewLine;
     });
 }
コード例 #3
0
        /// <summary>
        ///     Called by the NLog method logging target, this method fires the Changed event with the thread ID, timestamp, level,
        ///     logger and message associated with the new log message.
        /// </summary>
        /// <param name="threadID">The ID of the thread that originated the log message.</param>
        /// <param name="dateTime">The timestamp of the log message in long date format.</param>
        /// <param name="level">The level of the log message.</param>
        /// <param name="logger">The logger instance that generated the message.</param>
        /// <param name="message">The log message.</param>
        public static void AppendLog(string threadID, string dateTime, string level, string logger, string message)
        {
            RealtimeLoggerEventArgs eventArgs = new RealtimeLoggerEventArgs(threadID, dateTime, level, logger, message);

            AppendLogHistory(eventArgs);

            if (LogAppended != null)
            {
                LogAppended(default(object), eventArgs);
            }
        }