Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rawContent"></param>
        /// <param name="level"></param>
        public void AddEntry(string rawContent, LevelFlags level)
        {
            var logEntry = new LogEntry2();

            logEntry.Add(LogFileColumns.RawContent, rawContent);
            logEntry.Add(LogFileColumns.LogLevel, level);
            Add(logEntry);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rawContent"></param>
        public void AddEntry(string rawContent)
        {
            var logEntry = new LogEntry2();

            logEntry.Add(LogFileColumns.RawContent, rawContent);
            Add(logEntry);
        }
Ejemplo n.º 3
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)
            {
                LogEntryIndex logEntryIndex;
                TimeSpan?     elapsed, deltaTime;
                if (_logEntries.Count > 0)
                {
                    var first = _logEntries[0];
                    var last  = _logEntries[_logEntries.Count - 1];

                    logEntryIndex = last.LogEntryIndex + 1;
                    elapsed       = timestamp - first.Timestamp;
                    deltaTime     = timestamp - last.Timestamp;
                }
                else
                {
                    logEntryIndex = 0;
                    elapsed       = null;
                    deltaTime     = null;

                    _properties.SetValue(LogFileProperties.StartTimestamp, timestamp);
                }
                _properties.SetValue(LogFileProperties.EndTimestamp, timestamp);

                foreach (var line in lines)
                {
                    var logEntry = new LogEntry2();
                    logEntry.Add(LogFileColumns.Index, _logEntries.Count);
                    logEntry.Add(LogFileColumns.OriginalIndex, _logEntries.Count);
                    logEntry.Add(LogFileColumns.LineNumber, _logEntries.Count + 1);
                    logEntry.Add(LogFileColumns.OriginalLineNumber, _logEntries.Count + 1);
                    logEntry.Add(LogFileColumns.LogEntryIndex, logEntryIndex);
                    logEntry.Add(LogFileColumns.RawContent, line);
                    logEntry.Add(LogFileColumns.LogLevel, level);
                    logEntry.Add(LogFileColumns.Timestamp, timestamp);
                    logEntry.Add(LogFileColumns.ElapsedTime, elapsed);
                    logEntry.Add(LogFileColumns.DeltaTime, deltaTime);
                    _logEntries.Add(logEntry);
                    MaxCharactersPerLine = Math.Max(MaxCharactersPerLine, line.Length);
                }
                Touch();
                _listeners.OnRead(_logEntries.Count);
            }
        }