示例#1
0
        public RollingFilesMedia(
            LogMedia.IFileSystem fileSystem,
            Type logReaderType,
            StreamBasedFormatInfo logFormatInfo,
            LJTraceSource traceSource,
            IRollingFilesMediaStrategy rollingStrategy,
            ITempFilesManager tempFilesManager,
            ITraceSourceFactory traceSourceFactory)
        {
            this.traceSourceFactory = traceSourceFactory;
            trace = traceSource;
            using (trace.NewFrame)
            {
                if (fileSystem == null)
                {
                    throw new ArgumentNullException("fileSystem");
                }

                this.rollingStrategy  = rollingStrategy;
                this.logReaderType    = logReaderType;
                this.logFormatInfo    = logFormatInfo;
                this.tempFilesManager = tempFilesManager;

                try
                {
                    this.fileSystem    = fileSystem;
                    this.baseDirectory = rollingStrategy.BaseDirectory;
                    trace.Info("Base file directory: {0}", baseDirectory);

                    this.concatStream = new ConcatReadingStream();
                    this.tempThreads  = new LogSourceThreads(LJTraceSource.EmptyTracer, new ModelThreads(), null);

                    this.fsWatcher                     = fileSystem.CreateWatcher();
                    this.fsWatcher.Path                = this.baseDirectory;
                    this.fsWatcher.Created            += new FileSystemEventHandler(fsWatcher_Created);
                    this.fsWatcher.Renamed            += new RenamedEventHandler(fsWatcher_Renamed);
                    this.fsWatcher.EnableRaisingEvents = true;

                    trace.Info("Watcher enabled");

                    this.folderNeedsRescan = 1;
                }
                catch
                {
                    trace.Error("Initialization failed. Disposing.");
                    Dispose();
                    throw;
                }
            }
        }
示例#2
0
        public RollingFilesMedia(
            LogMedia.IFileSystem fileSystem,
            Func <MediaBasedReaderParams, IPositionedMessagesReader> readerCreator,
            LJTraceSource traceSource,
            IRollingFilesMediaStrategy rollingStrategy)
        {
            trace = traceSource;
            using (trace.NewFrame)
            {
                if (fileSystem == null)
                {
                    throw new ArgumentNullException(nameof(fileSystem));
                }

                this.rollingStrategy = rollingStrategy;
                this.readerCreator   = readerCreator;

                try
                {
                    this.fileSystem    = fileSystem;
                    this.baseDirectory = rollingStrategy.BaseDirectory;
                    trace.Info("Base file directory: {0}", baseDirectory);

                    this.concatStream = new ConcatReadingStream();
                    this.tempThreads  = new LogSourceThreads(LJTraceSource.EmptyTracer, new ModelThreads(), null);

                    this.fsWatcher                     = fileSystem.CreateWatcher();
                    this.fsWatcher.Path                = this.baseDirectory;
                    this.fsWatcher.Created            += new FileSystemEventHandler(fsWatcher_Created);
                    this.fsWatcher.Renamed            += new RenamedEventHandler(fsWatcher_Renamed);
                    this.fsWatcher.EnableRaisingEvents = true;

                    trace.Info("Watcher enabled");

                    this.folderNeedsRescan = 1;
                }
                catch
                {
                    trace.Error("Initialization failed. Disposing.");
                    Dispose();
                    throw;
                }
            }
        }