/// <summary>
 /// Stores the message log entry.
 /// </summary>
 /// <param name="entry">The log message entry.</param>
 private void PushIntoQueue(MemoryLogEntry entry)
 {
     if (LogMessages.Count >= _settings.MemoryCacheSize)
     {
         MemoryLogEntry result;
         LogMessages.TryDequeue(out result);
     }
     LogMessages.Enqueue(entry);
 }
        /// <summary>
        /// Write a message into the memory log.
        /// </summary>
        /// <param name="logLevel">Entry will be written on this level.</param>v
        /// <param name="logName">The category log name.</param>
        /// <param name="eventId">Id of the event.</param>
        /// <param name="message">The log message.</param>
        /// <param name="scope">The logging scope flag.</param>
        /// <param name="exception">The exception related to this entry.</param>
        public virtual void WriteMessage(LogLevel logLevel, string logName, EventId eventId, string message, string scope, Exception exception)
        {
            MemoryLogEntry logEntry = new MemoryLogEntry()
            {
                EventId  = eventId,
                LogLevel = logLevel,
                LogName  = logName,
                Scope    = scope
            };

            if (!string.IsNullOrEmpty(message))
            {
                logEntry.Message = message;
            }

            if (exception != null)
            {
                logEntry.Exception = exception;
            }
            PushIntoQueue(logEntry);
        }