Esempio n. 1
0
        /// <summary>
        ///     Initializes this object.
        /// </summary>
        /// <remarks>
        ///    Plugin authors are deliberately prevented from calling this constructor directly because it's signature may change
        ///    over time. In order to create an instance of this type, simply call <see cref="IServiceContainer.CreateMergedLogFile"/>.
        /// </remarks>
        /// <param name="scheduler"></param>
        /// <param name="maximumWaitTime"></param>
        /// <param name="sources"></param>
        internal MergedLogFile(ITaskScheduler scheduler, TimeSpan maximumWaitTime, params ILogFile[] sources)
            : base(scheduler)
        {
            if (sources == null)
            {
                throw new ArgumentNullException(nameof(sources));
            }
            if (sources.Any(x => x == null))
            {
                throw new ArgumentException("sources.Any(x => x == null)", nameof(sources));
            }
            if (sources.Length > LogLineSourceId.MaxSources)
            {
                throw new ArgumentException(string.Format("Only up to {0} sources are supported ({1} were given)", LogLineSourceId.MaxSources, sources.Length));
            }

            _sources = sources;
            _index   = new MergedLogFileIndex(sources);
            _pendingModifications = new ConcurrentQueue <MergedLogFilePendingModification>();
            var logFileIndices = new Dictionary <ILogFile, byte>();

            _maximumWaitTime = maximumWaitTime;
            _properties      = new LogFilePropertyList(LogFileProperties.Minimum);

            byte idx = 0;

            foreach (var logFile in _sources)
            {
                logFile.AddListener(this, maximumWaitTime, MaximumBatchSizePerSource);
                logFileIndices.Add(logFile, idx);

                ++idx;
            }
            StartTask();
        }
Esempio n. 2
0
 /// <inheritdoc />
 public void GetValues(ILogFileProperties properties)
 {
     try
     {
         _logFile.GetValues(properties);
     }
     catch (Exception e)
     {
         BlameExceptionOnPlugin(e);
         throw;
     }
 }
Esempio n. 3
0
        /// <summary>
        ///     Initializes this object.
        /// </summary>
        /// <param name="columns"></param>
        public InMemoryLogFile(IEnumerable <ILogFileColumn> columns)
        {
            if (columns == null)
            {
                throw new ArgumentNullException(nameof(columns));
            }

            _syncRoot   = new object();
            _logEntries = new LogEntryList(LogFileColumns.CombineWithMinimum(columns));
            _listeners  = new LogFileListenerCollection(this);

            _properties = new LogFilePropertyList(LogFileProperties.Minimum);
            _properties.SetValue(LogFileProperties.Size, Size.Zero);
        }
Esempio n. 4
0
        /// <inheritdoc />
        public void GetValues(ILogFileProperties properties)
        {
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            foreach (var propertyDescriptor in properties.Properties)
            {
                object value;
                if (TryGetValue(propertyDescriptor, out value))
                {
                    properties.SetValue(propertyDescriptor, value);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes this text log file.
        /// </summary>
        /// <param name="scheduler"></param>
        /// <param name="fileName"></param>
        /// <param name="timestampParser">An optional timestamp parser that is used to find timestamps in log messages. If none is specified, then <see cref="TimestampParser"/> is used</param>
        /// <param name="translator">An optional translator that is used to translate each log line in memory. If none is specified, then log lines are displayed as they are in the file on disk</param>
        /// <param name="encoding">The encoding to use to interpet the file, if none is specified, then <see cref="Encoding.UTF8"/> is used</param>
        public TextLogFile(ITaskScheduler scheduler,
                           string fileName,
                           ITimestampParser timestampParser = null,
                           ILogLineTranslator translator    = null,
                           Encoding encoding = null)
            : base(scheduler)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            _fileName     = fileName;
            _fullFilename = fileName;
            if (!Path.IsPathRooted(_fullFilename))
            {
                _fullFilename = Path.Combine(Directory.GetCurrentDirectory(), fileName);
            }

            if (translator != null)
            {
                _translator = new NoThrowLogLineTranslator(translator);
            }

            _entries    = new List <LogLine>();
            _properties = new LogFilePropertyList(LogFileProperties.Minimum);
            _properties.SetValue(LogFileProperties.Name, _fileName);
            _syncRoot = new object();
            _encoding = encoding ?? Encoding.UTF8;

            Log.DebugFormat("Log File '{0}' is interpreted using {1}", _fileName, _encoding.EncodingName);

            if (timestampParser != null)
            {
                _timestampParser = new NoThrowTimestampParser(timestampParser);
            }
            else
            {
                _timestampParser = new TimestampParser();
            }

            StartTask();
        }
Esempio n. 6
0
        /// <inheritdoc />
        public void GetValues(ILogFileProperties properties)
        {
            var logFile = _innerLogFile;

            if (logFile != null)
            {
                logFile.GetValues(properties);
            }
            else
            {
                foreach (var descriptor in properties.Properties)
                {
                    if (Equals(descriptor, LogFileProperties.EmptyReason))
                    {
                        properties.SetValue(descriptor, ErrorFlags.SourceDoesNotExist);
                    }
                    else
                    {
                        properties.SetValue(descriptor, descriptor.DefaultValue);
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        ///     Initializes this object.
        /// </summary>
        /// <remarks>
        ///    Plugin authors are deliberately prevented from calling this constructor directly because it's signature may change
        ///    over time. In order to create an instance of this type, simply call <see cref="IServiceContainer.CreateMultiLineLogFile"/>.
        /// </remarks>
        /// <param name="taskScheduler"></param>
        /// <param name="source"></param>
        /// <param name="maximumWaitTime"></param>
        public MultiLineLogFile(ITaskScheduler taskScheduler, ILogFile source, TimeSpan maximumWaitTime)
            : base(taskScheduler)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            _maximumWaitTime      = maximumWaitTime;
            _pendingModifications = new ConcurrentQueue <LogFileSection>();
            _syncRoot             = new object();
            _indices = new List <LogEntryInfo>();

            // The log file we were given might offer even more properties than the minimum set and we
            // want to expose those as well.
            _properties = new LogFilePropertyList(LogFileProperties.CombineWithMinimum(source.Properties));
            _properties.SetValue(LogFileProperties.EmptyReason, ErrorFlags.SourceDoesNotExist);

            _currentLogEntry = new LogEntryInfo(-1, 0);

            _source = source;
            _source.AddListener(this, maximumWaitTime, MaximumBatchSize);
            StartTask();
        }
Esempio n. 8
0
 /// <inheritdoc />
 public override void GetValues(ILogFileProperties properties)
 {
     _properties.GetValues(properties);
 }
 /// <summary>
 ///     Initializes this object.
 /// </summary>
 /// <param name="properties"></param>
 public LogFilePropertiesView(ILogFileProperties properties)
 {
     _properties = properties;
 }
Esempio n. 10
0
 public override void GetValues(ILogFileProperties properties)
 {
     throw new NotImplementedException();
 }
Esempio n. 11
0
 /// <inheritdoc />
 public void GetValues(ILogFileProperties properties)
 {
     _buffer.GetValues(properties);
 }
Esempio n. 12
0
 /// <inheritdoc />
 public abstract void GetValues(ILogFileProperties properties);