/// <summary> /// Initializes this text log file. /// </summary> /// <param name="taskScheduler"></param> /// <param name="fileName"></param> /// <param name="format"></param> /// <param name="encoding"></param> internal StreamingTextLogSource(ITaskScheduler taskScheduler, string fileName, ILogFileFormat format, Encoding encoding) { _taskScheduler = taskScheduler; _encoding = encoding; _listeners = new LogSourceListenerCollection(this); _sourceDoesNotExist = new SourceDoesNotExist(fileName); _sourceCannotBeAccessed = new SourceCannotBeAccessed(fileName); _fileName = fileName ?? throw new ArgumentNullException(nameof(fileName)); _index = new LogBufferList(StreamingTextLogSource.LineOffsetInBytes); _propertiesBuffer = new PropertiesBufferList(); _propertiesBuffer.SetValue(Core.Properties.Name, _fileName); _propertiesBuffer.SetValue(Core.Properties.Format, format); _propertiesBuffer.SetValue(TextProperties.RequiresBuffer, true); _propertiesBuffer.SetValue(TextProperties.LineCount, 0); _properties = new ConcurrentPropertiesList(Core.Properties.Minimum); SynchronizeProperties(); _cancellationTokenSource = new CancellationTokenSource(); _columns = new IColumnDescriptor[] { Core.Columns.Index, StreamingTextLogSource.LineOffsetInBytes, Core.Columns.RawContent }; _pendingReadRequests = new ConcurrentQueue <IReadRequest>(); _fileScanTask = _taskScheduler.StartPeriodic(() => RunFileScan(_cancellationTokenSource.Token)); _fileReadTask = _taskScheduler.StartPeriodic(() => RunFileRead(_cancellationTokenSource.Token)); }
/// <summary> /// Initializes this log file. /// </summary> /// <param name="scheduler"></param> protected AbstractLogSource(ITaskScheduler scheduler) { if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } _scheduler = scheduler; _cancellationTokenSource = new CancellationTokenSource(); Listeners = new LogSourceListenerCollection(this); }
/// <summary> /// Initializes this object. /// </summary> /// <param name="taskScheduler"></param> /// <param name="maximumWaitTime"></param> /// <param name="maxEntryCount"></param> public LogSourceProxy(ITaskScheduler taskScheduler, TimeSpan maximumWaitTime, int maxEntryCount = DefaultMaxEntryCount) { if (taskScheduler == null) { throw new ArgumentNullException(nameof(taskScheduler)); } _taskScheduler = taskScheduler; _properties = new ConcurrentPropertiesList(Core.Properties.Minimum); _properties.SetValue(Core.Properties.EmptyReason, null); _sourceProperties = new PropertiesBufferList(); _pendingSections = new ConcurrentQueue <KeyValuePair <ILogSource, LogSourceModification> >(); _listeners = new LogSourceListenerCollection(this); _task = _taskScheduler.StartPeriodic(RunOnce, "Log File Proxy"); _maximumWaitTime = maximumWaitTime; _maxEntryCount = maxEntryCount; }
/// <summary> /// Initializes this object. /// </summary> /// <param name="columns"></param> /// <param name="properties"></param> public InMemoryLogSource(IEnumerable <IColumnDescriptor> columns, IReadOnlyDictionary <IReadOnlyPropertyDescriptor, object> properties) { if (columns == null) { throw new ArgumentNullException(nameof(columns)); } _syncRoot = new object(); _logBuffer = new LogBufferList(Core.Columns.CombineWithMinimum(columns)); _listeners = new LogSourceListenerCollection(this); _properties = new PropertiesBufferList(Core.Properties.Minimum); _properties.SetValue(Core.Properties.Size, Size.Zero); _properties.SetValue(Core.Properties.PercentageProcessed, Percentage.HundredPercent); foreach (var pair in properties) { _properties.SetValue(pair.Key, pair.Value); } }