NLog.Targets.FileTarget.ProcessLogEvent C# (CSharp) Method

ProcessLogEvent() private method

private ProcessLogEvent ( LogEventInfo logEvent, string fileName, byte bytesToWrite ) : void
logEvent LogEventInfo
fileName string
bytesToWrite byte
return void
        private void ProcessLogEvent(LogEventInfo logEvent, string fileName, byte[] bytesToWrite)
        {
            TryArchiveFile(fileName, logEvent, bytesToWrite.Length);

            // Clean up old archives if this is the first time a log record is being written to
            // this log file and the archiving system is date/time based.
            if (this.ArchiveNumbering == ArchiveNumberingMode.Date && this.ArchiveEvery != FileArchivePeriod.None &&
                ShouldDeleteOldArchives())
            {
                if (!previousFileNames.Contains(fileName))
                {
                    if (this.previousFileNames.Count > this.maxLogFilenames)
                    {
                        this.previousFileNames.Dequeue();
                    }

                    string fileNamePattern = this.GetArchiveFileNamePattern(fileName, logEvent);
                    if (fileNamePattern != null)
                    {
                        this.DeleteOldDateArchives(fileNamePattern);
                    }
                    this.previousFileNames.Enqueue(fileName);
                }
            }

            this.WriteToFile(fileName, logEvent, bytesToWrite, false);

            previousLogFileName = fileName;
            previousLogEventTimestamp = logEvent.TimeStamp;
        }