/// <summary>
        /// Initialises an instance of the <see cref="LogContainer"/> class.
        /// </summary>
        /// <param name="items">
        /// The items to populate the container with.
        /// </param>
        public LogContainer(LogEntry[] items) : this()
        {
            items.ShouldNotBeNull();

            foreach (var item in items)
            {
                m_Count = AddLogEntry(item);
            }
        }
        /// <summary>
        /// See <see cref="ILogProvider.Log"/> for more details.
        /// </summary>
        /// <param name="entry">
        /// The log entry to process.
        /// </param>
        public void Log(LogEntry entry)
        {
            var timestamp = entry.TimeStamp;

            var builder = new StringBuilder(timestamp.ToString("yyyy-MM-dd HH:mm:ss."));
            builder.Append(timestamp.Millisecond.ToString("D3"));
            builder.Append(" | ");
            builder.Append(entry.Win32ThreadId);
            builder.Append(" | ");
            builder.Append(entry.LoggerName);
            builder.Append(" | ");
            builder.Append(entry.Message);

            if (entry.BaseException != null)
            {
                builder.Append(" | ");
                builder.Append(entry.BaseException.Message);
                builder.Append(" | ");
                builder.Append(entry.BaseException.StackTrace);
            }

            Debug.Print(builder.ToString());
        }
        /// <summary>
        /// See <see cref="ILogProvider.Log"/> for more details.
        /// </summary>
        /// <param name="entry">
        /// The logging entry to add.
        /// </param>
        public void Log(LogEntry entry)
        {
            entry.ShouldNotBeNull();

            entry.SetLoggerName(m_LoggerName);
            if (IsLoggingEnabled)
            {
                m_LogContainer.AddLogEntry(entry);
            }
        }
        /// <summary>
        /// Adds a new logging entry to the proxy service.
        /// </summary>
        /// <remarks>
        /// Will add a new log entry in a thread safe manner.
        /// </remarks>
        /// <param name="logEntry">
        /// The log entry to add.
        /// </param>
        public void AddLogEntry(LogEntry logEntry)
        {
            logEntry.ShouldNotBeNull();

            var count = m_LogEntries.AddLogEntry(logEntry);
            if (count >= m_BatchSize)
            {
                SignalWorkToBeDone();
            }
        }
        /// <summary>
        /// Builds a log entry.
        /// </summary>
        /// <param name="logMessage">
        /// The details of the log entry to be logged.
        /// </param>
        /// <returns>
        /// A <see cref="LogEntry"/> containing the unique identifier of the log entry, and the log entry itself.
        /// </returns>
        internal LogEntry BuildLogEntry(LogMessage logMessage)
        {
            string logEntryId = BuildNextLogNumber();

            var logEntry = new LogEntry(logEntryId);
            logEntry.Message = CreateLogMessage(logMessage.Message, logMessage.Exception);
            logEntry.EventId = 0;
            logEntry.Priority = 1;
            logEntry.TimeStamp = DateTime.UtcNow;
            logEntry.MachineName = MachineName;
            logEntry.Win32ThreadId = Thread.CurrentThread.ManagedThreadId.ToString();

            if (logMessage.Exception != null)
            {
                logEntry.ExtendedProperties["errorCategory"] = logMessage.Exception.ErrorCode.Category;
                logEntry.ExtendedProperties["errorSeverity"] = logMessage.Exception.ErrorCode.Severity;
                logEntry.ExtendedProperties["errorType"] = logMessage.Exception.ErrorCode.ErrorType;
            }
            else
            {
                logEntry.ExtendedProperties["errorCategory"] = logMessage.ErrorCode.Category;
                logEntry.ExtendedProperties["errorSeverity"] = logMessage.ErrorCode.Severity;
                logEntry.ExtendedProperties["errorType"] = logMessage.ErrorCode.ErrorType;
            }

            return logEntry;
        }
        /// <summary>
        /// Adds a new <see cref="LogEntry"/> to the container.
        /// </summary>
        /// <param name="entry">
        /// A single log entry to be added to the container.
        /// </param>
        public int AddLogEntry(LogEntry entry)
        {
            int itemCount = 0;

            if (entry != null)
            {
                lock (m_Synclock)
                {
                    m_LogEntries.Enqueue(entry);

                    itemCount = m_LogEntries.Count;
                    m_Count = itemCount;
                }
            }

            return itemCount;
        }