Ejemplo n.º 1
0
        /// <summary>
        ///     Adds a multi line log entry to this log file.
        /// </summary>
        /// <param name="level"></param>
        /// <param name="timestamp"></param>
        /// <param name="lines"></param>
        public void AddMultilineEntry(LevelFlags level, DateTime?timestamp, params string[] lines)
        {
            lock (_syncRoot)
            {
                UpdateTimestampProperties(timestamp);
                var logEntryIndex = GetLogEntryIndex(timestamp, out var elapsed, out var deltaTime);

                foreach (var line in lines)
                {
                    var logEntry = new LogEntry
                    {
                        Index              = _logBuffer.Count,
                        OriginalIndex      = _logBuffer.Count,
                        LineNumber         = _logBuffer.Count + 1,
                        OriginalLineNumber = _logBuffer.Count + 1,
                        LogEntryIndex      = logEntryIndex,
                        RawContent         = line,
                        LogLevel           = level,
                        Timestamp          = timestamp,
                        ElapsedTime        = elapsed,
                        DeltaTime          = deltaTime
                    };
                    _logBuffer.Add(logEntry);
                    SetValue(Core.Properties.LogEntryCount, _logBuffer.Count);
                    SetValue(TextProperties.MaxCharactersInLine, Math.Max(GetProperty(TextProperties.MaxCharactersInLine), line.Length));
                }
                Touch();
                _listeners.OnRead(_logBuffer.Count);
            }
        }
Ejemplo n.º 2
0
 private void TryAddLogLine(IReadOnlyLogEntry logEntry)
 {
     // We have a filter that operates on individual lines (regardless of log entry affiliation).
     // We therefore have to evaluate each line for itself before we can even begin to consider adding a log
     // entry.
     if (_logLineFilter.PassesFilter(logEntry))
     {
         _lastLogBuffer.Add(logEntry);
     }
 }
Ejemplo n.º 3
0
        private void Add(string line, int numberOfLinesRead)
        {
            lock (_syncRoot)
            {
                _entries.Add(new LogEntry
                {
                    RawContent = line
                });
            }

            Listeners.OnRead(numberOfLinesRead);
        }