コード例 #1
0
 public FormatAutodetect(Func <ILogProviderFactory, int> mruIndexGetter, ILogProviderFactoryRegistry factoriesRegistry,
                         ITraceSourceFactory traceSourceFactory)
 {
     this.mruIndexGetter     = mruIndexGetter;
     this.factoriesRegistry  = factoriesRegistry;
     this.traceSourceFactory = traceSourceFactory;
 }
コード例 #2
0
 public Factory(
     IAlertPopup alerts,
     IFileDialogs fileDialogs,
     Help.IPresenter help,
     ILogProviderFactoryRegistry registry,
     IFormatDefinitionsRepository repo,
     IUserDefinedFormatsManager userDefinedFormatsManager,
     ITempFilesManager tempFilesManager,
     ITraceSourceFactory traceSourceFactory,
     RegularExpressions.IRegexFactory regexFactory,
     LogViewer.IPresenterFactory logViewerPresenterFactory,
     IViewsFactory viewFactories,
     ISynchronizationContext synchronizationContext,
     FieldsProcessor.IFactory fieldsProcessorFactory
     )
 {
     this.viewFactories             = viewFactories;
     this.alerts                    = alerts;
     this.registry                  = registry;
     this.fileDialogs               = fileDialogs;
     this.userDefinedFormatsManager = userDefinedFormatsManager;
     this.help                      = help;
     this.repo                      = repo;
     this.tempFilesManager          = tempFilesManager;
     this.logViewerPresenterFactory = logViewerPresenterFactory;
     this.traceSourceFactory        = traceSourceFactory;
     this.regexFactory              = regexFactory;
     this.synchronizationContext    = synchronizationContext;
     this.fieldsProcessorFactory    = fieldsProcessorFactory;
 }
コード例 #3
0
 public PreprocessingStepsFactory(
     Workspaces.IWorkspacesManager workspacesManager,
     AppLaunch.ILaunchUrlParser appLaunch,
     ISynchronizationContext invoke,
     IExtensionsRegistry extentions,
     Progress.IProgressAggregator progressAggregator,
     Persistence.IWebContentCache cache,
     ICredentialsCache credCache,
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     WebViewTools.IWebViewTools webBrowserDownloader,
     ILogsDownloaderConfig logsDownloaderConfig,
     RegularExpressions.IRegexFactory regexFactory
     )
 {
     this.workspacesManager  = workspacesManager;
     this.appLaunch          = appLaunch;
     this.invoke             = invoke;
     this.extentions         = extentions;
     this.progressAggregator = progressAggregator;
     this.cache     = cache;
     this.credCache = credCache;
     this.logProviderFactoryRegistry = logProviderFactoryRegistry;
     this.webViewTools         = webBrowserDownloader;
     this.logsDownloaderConfig = logsDownloaderConfig;
     this.regexFactory         = regexFactory;
 }
コード例 #4
0
ファイル: WorkspacesManager.cs プロジェクト: cxsun/logjoint
 public WorkspacesManager(
     ILogSourcesManager logSources,
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     IStorageManager storageManager,
     Backend.IBackendAccess backend,
     ITempFilesManager tempFilesManager,
     MRU.IRecentlyUsedEntities recentlyUsedEntities,
     IShutdown shutdown,
     ITraceSourceFactory traceSourceFactory
     )
 {
     this.tracer                     = traceSourceFactory.CreateTraceSource("Workspaces", "ws");
     this.logSources                 = logSources;
     this.backendAccess              = backend;
     this.tempFilesManager           = tempFilesManager;
     this.logProviderFactoryRegistry = logProviderFactoryRegistry;
     this.storageManager             = storageManager;
     this.recentlyUsedEntities       = recentlyUsedEntities;
     if (backend.IsConfigured)
     {
         this.status = WorkspacesManagerStatus.NoWorkspace;
     }
     else
     {
         this.status = WorkspacesManagerStatus.Unavailable;
     }
     shutdown.Cleanup += (s, e) => shutdown.AddCleanupTask(
         WaitUploadCompletion().WithTimeout(TimeSpan.FromSeconds(10)));
 }
コード例 #5
0
ファイル: FormatAutodetect.cs プロジェクト: rkapl123/logjoint
 public FormatAutodetect(Func <ILogProviderFactory, int> mruIndexGetter, ILogProviderFactoryRegistry factoriesRegistry,
                         ITraceSourceFactory traceSourceFactory, LogMedia.IFileSystem fileSystem)
 {
     this.mruIndexGetter     = mruIndexGetter;
     this.factoriesRegistry  = factoriesRegistry;
     this.traceSourceFactory = traceSourceFactory;
     this.fileSystem         = fileSystem;
 }
コード例 #6
0
ファイル: RecentLogEntry.cs プロジェクト: sabrogden/logjoint
        public static ILogProviderFactory ParseFactoryPart(ILogProviderFactoryRegistry registry, string recentLogEntryString)
        {
            var    m       = MatchRecentLogEntryString(recentLogEntryString);
            string company = m.Groups["company"].Value;
            string name    = m.Groups["name"].Value;

            return(registry.Find(company, name));
        }
コード例 #7
0
        static DetectedFormat DetectFormat(
            string fileName,
            Func <ILogProviderFactory, int> mruIndexGetter,
            ILogProviderFactoryRegistry factoriesRegistry,
            CancellationToken cancellation,
            IFormatAutodetectionProgress progress,
            ITempFilesManager tempFilesManager)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("fileName");
            }
            if (mruIndexGetter == null)
            {
                throw new ArgumentNullException("mru");
            }
            var log = LJTraceSource.EmptyTracer;

            using (log.NewFrame)
                using (SimpleFileMedia fileMedia = new SimpleFileMedia(
                           SimpleFileMedia.CreateConnectionParamsFromFileName(fileName)))
                    using (ILogSourceThreads threads = new LogSourceThreads())
                    {
                        foreach (ILogProviderFactory factory in GetOrderedListOfRelevantFactories(fileName, mruIndexGetter, factoriesRegistry))
                        {
                            log.Info("Trying {0}", factory);
                            if (progress != null)
                            {
                                progress.Trying(factory);
                            }
                            if (cancellation.IsCancellationRequested)
                            {
                                return(null);
                            }
                            try
                            {
                                using (var reader = ((IMediaBasedReaderFactory)factory).CreateMessagesReader(
                                           new MediaBasedReaderParams(threads, fileMedia, tempFilesManager, MessagesReaderFlags.QuickFormatDetectionMode)))
                                {
                                    reader.UpdateAvailableBounds(false);
                                    using (var parser = reader.CreateParser(new CreateParserParams(0, null, MessagesParserFlag.DisableMultithreading, MessagesParserDirection.Forward)))
                                    {
                                        if (parser.ReadNext() != null)
                                        {
                                            log.Info("Autodetected format of {0}: {1}", fileName, factory);
                                            return(new DetectedFormat(factory, ((IFileBasedLogProviderFactory)factory).CreateParams(fileName)));
                                        }
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                log.Error(e, "Failed to load '{0}' as {1}", fileName, factory);
                            }
                        }
                    }
            return(null);
        }
コード例 #8
0
 static IEnumerable <ILogProviderFactory> GetOrderedListOfRelevantFactories(string fileName, Func <ILogProviderFactory, int> mruIndexGetter,
                                                                            ILogProviderFactoryRegistry factoriesRegistry)
 {
     return
         (from factory in factoriesRegistry.Items
          where factory is IFileBasedLogProviderFactory && factory is IMediaBasedReaderFactory
          orderby GetFilePatternsMatchRating(factory, fileName), mruIndexGetter(factory)
          select factory);
 }
コード例 #9
0
ファイル: Model.cs プロジェクト: pnelson786/logjoint
 public Model(
     IInvokeSynchronization threadSync,
     Telemetry.ITelemetryCollector telemetryCollector,
     Persistence.IWebContentCache webCache,
     Persistence.IContentCache contentCache,
     Persistence.IStorageManager storageManager,
     IBookmarks bookmarks,
     ILogSourcesManager sourcesManager,
     IModelThreads threads,
     ITempFilesManager tempFilesManager,
     Preprocessing.IPreprocessingManagerExtensionsRegistry preprocessingManagerExtentionsRegistry,
     Preprocessing.ILogSourcesPreprocessingManager logSourcesPreprocessingManager,
     Preprocessing.IPreprocessingStepsFactory preprocessingStepsFactory,
     Progress.IProgressAggregator progressAggregator,
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     IUserDefinedFormatsManager userDefinedFormatsManager,
     MRU.IRecentlyUsedEntities mru,
     Progress.IProgressAggregatorFactory progressAggregatorsFactory,
     IHeartBeatTimer heartbeat,
     ILogSourcesController logSourcesController,
     IShutdown shutdown,
     WebBrowserDownloader.IDownloader webBrowserDownloader,
     AppLaunch.ICommandLineHandler commandLineHandler,
     Postprocessing.IPostprocessorsManager postprocessorsManager,
     Postprocessing.IUserNamesProvider analyticsShortNames,
     Analytics.TimeSeries.ITimeSeriesTypesAccess timeSeriesTypes,
     Postprocessing.IAggregatingLogSourceNamesProvider logSourceNamesProvider
     )
 {
     this.ModelThreadSynchronization = threadSync;
     this.Telemetry        = telemetryCollector;
     this.WebContentCache  = webCache;
     this.ContentCache     = contentCache;
     this.StorageManager   = storageManager;
     this.Bookmarks        = bookmarks;
     this.SourcesManager   = sourcesManager;
     this.Threads          = threads;
     this.TempFilesManager = tempFilesManager;
     this.PreprocessingManagerExtensionsRegistry = preprocessingManagerExtentionsRegistry;
     this.PreprocessingStepsFactory      = preprocessingStepsFactory;
     this.LogSourcesPreprocessingManager = logSourcesPreprocessingManager;
     this.ProgressAggregator             = progressAggregator;
     this.LogProviderFactoryRegistry     = logProviderFactoryRegistry;
     this.UserDefinedFormatsManager      = userDefinedFormatsManager;
     this.ProgressAggregatorsFactory     = progressAggregatorsFactory;
     this.MRU                    = mru;
     this.Heartbeat              = heartbeat;
     this.LogSourcesController   = logSourcesController;
     this.Shutdown               = shutdown;
     this.WebBrowserDownloader   = webBrowserDownloader;
     this.CommandLineHandler     = commandLineHandler;
     this.PostprocessorsManager  = postprocessorsManager;
     this.ShortNames             = analyticsShortNames;
     this.TimeSeriesTypes        = timeSeriesTypes;
     this.LogSourceNamesProvider = logSourceNamesProvider;
 }
コード例 #10
0
ファイル: AppInitializer.cs プロジェクト: pnelson786/logjoint
 public AppInitializer(
     LJTraceSource tracer,
     IUserDefinedFormatsManager userDefinedFormatsManager,
     ILogProviderFactoryRegistry factoryRegistry,
     ITempFilesManager tempFiles)
 {
     InitializePlatform(tracer);
     InitLogFactories(userDefinedFormatsManager, factoryRegistry, tempFiles);
     userDefinedFormatsManager.ReloadFactories();
 }
コード例 #11
0
ファイル: AppInitializer.cs プロジェクト: pnelson786/logjoint
 static void InitLogFactories(
     IUserDefinedFormatsManager userDefinedFormatsManager,
     ILogProviderFactoryRegistry factoryRegistry,
     ITempFilesManager tempFiles)
 {
     RegularGrammar.UserDefinedFormatFactory.Register(userDefinedFormatsManager);
     XmlFormat.UserDefinedFormatFactory.Register(userDefinedFormatsManager);
     JsonFormat.UserDefinedFormatFactory.Register(userDefinedFormatsManager);
     factoryRegistry.Register(new PlainText.Factory(tempFiles));
     factoryRegistry.Register(new XmlFormat.NativeXMLFormatFactory(tempFiles));
 }
コード例 #12
0
 internal TimeAnomalyFixingStep(
     PreprocessingStepParams srcFile,
     Progress.IProgressAggregator progressAggregator,
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     IPreprocessingStepsFactory preprocessingStepsFactory)
 {
     this.sourceFile = srcFile;
     this.preprocessingStepsFactory  = preprocessingStepsFactory;
     this.progressAggregator         = progressAggregator;
     this.logProviderFactoryRegistry = logProviderFactoryRegistry;
 }
コード例 #13
0
 internal TimeAnomalyFixingStep(
     PreprocessingStepParams srcFile,
     Progress.IProgressAggregator progressAggregator,
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     IStepsFactory preprocessingStepsFactory,
     RegularExpressions.IRegexFactory regexFactory)
 {
     this.@params = srcFile;
     this.preprocessingStepsFactory  = preprocessingStepsFactory;
     this.progressAggregator         = progressAggregator;
     this.logProviderFactoryRegistry = logProviderFactoryRegistry;
     this.regexFactory = regexFactory;
 }
コード例 #14
0
        private static void RegisterPredefinedFormatFactories(
            ILogProviderFactoryRegistry logProviderFactoryRegistry,
            ITempFilesManager tempFilesManager,
            IUserDefinedFormatsManager userDefinedFormatsManager)
        {
#if WIN
            logProviderFactoryRegistry.Register(new DebugOutput.Factory());
            logProviderFactoryRegistry.Register(new WindowsEventLog.Factory());
#endif
            logProviderFactoryRegistry.Register(new PlainText.Factory(tempFilesManager));
            logProviderFactoryRegistry.Register(new XmlFormat.NativeXMLFormatFactory(tempFilesManager));
            userDefinedFormatsManager.ReloadFactories();
        }
コード例 #15
0
 public UserDefinedFormatsManager(
     IFormatDefinitionsRepository repository,
     ILogProviderFactoryRegistry registry,
     ITempFilesManager tempFilesManager,
     ITraceSourceFactory traceSourceFactory
     )
 {
     this.repository         = repository ?? throw new ArgumentNullException(nameof(repository));
     this.registry           = registry ?? throw new ArgumentNullException(nameof(registry));
     this.tempFilesManager   = tempFilesManager;
     this.traceSourceFactory = traceSourceFactory;
     this.tracer             = traceSourceFactory.CreateTraceSource("UserDefinedFormatsManager", "udfm");
 }
コード例 #16
0
        public UserDefinedFormatsManager(IFormatDefinitionsRepository repository, ILogProviderFactoryRegistry registry, ITempFilesManager tempFilesManager)
        {
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }
            if (registry == null)
            {
                throw new ArgumentNullException("registry");
            }

            this.repository       = repository;
            this.registry         = registry;
            this.tempFilesManager = tempFilesManager;
        }
コード例 #17
0
ファイル: Factory.cs プロジェクト: sabrogden/logjoint
 private static void RegisterPredefinedFormatFactories(
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     ITempFilesManager tempFilesManager,
     IUserDefinedFormatsManager userDefinedFormatsManager,
     RegularExpressions.IRegexFactory regexFactory,
     ITraceSourceFactory traceSourceFactory)
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         RegisterWindowsOnlyFactories(logProviderFactoryRegistry);
     }
     logProviderFactoryRegistry.Register(new PlainText.Factory(tempFilesManager));
     logProviderFactoryRegistry.Register(new XmlFormat.NativeXMLFormatFactory(tempFilesManager, regexFactory, traceSourceFactory));
     userDefinedFormatsManager.ReloadFactories();
 }
コード例 #18
0
ファイル: RecentLogEntry.cs プロジェクト: sabrogden/logjoint
        public RecentLogEntry(ILogProviderFactoryRegistry registry, string recentLogEntryString, string annotation, DateTime?useTimestampUtc)
        {
            var    m       = MatchRecentLogEntryString(recentLogEntryString);
            string company = m.Groups["company"].Value;
            string name    = m.Groups["name"].Value;

            this.Factory = registry.Find(company, name);
            if (Factory == null)
            {
                throw new FormatNotRegistedException(company, name);
            }
            this.ConnectionParams = new ConnectionParams(m.Groups["connectStr"].Value);
            ConnectionParamsUtils.ValidateConnectionParams(ConnectionParams, Factory);
            this.Annotation      = annotation;
            this.UseTimestampUtc = useTimestampUtc;
        }
コード例 #19
0
 public Presenter(
     IView view,
     IWizardScenarioHost host,
     IAlertPopup alerts,
     ILogProviderFactoryRegistry registry,
     bool newFormatMode
     )
 {
     this.view = view;
     this.view.SetEventsHandler(this);
     this.host          = host;
     this.alerts        = alerts;
     this.newFormatMode = newFormatMode;
     this.registry      = registry;
     this.view[ControlId.HeaderLabel] = newFormatMode ? "New format properties:" : "Format properties";
 }
コード例 #20
0
ファイル: Model.cs プロジェクト: rkapl123/logjoint
 public Model(
     ISynchronizationContext threadSync,
     IChangeNotification changeNotification,
     Persistence.IWebContentCache webCache,
     Persistence.IContentCache contentCache,
     Persistence.IStorageManager storageManager,
     IBookmarks bookmarks,
     ILogSourcesManager sourcesManager,
     IModelThreads threads,
     ITempFilesManager tempFilesManager,
     Preprocessing.IModel preprocessingModel,
     Progress.IProgressAggregator progressAggregator,
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     IUserDefinedFormatsManager userDefinedFormatsManager,
     MRU.IRecentlyUsedEntities mru,
     Progress.IProgressAggregatorFactory progressAggregatorsFactory,
     IShutdown shutdown,
     WebViewTools.IWebViewTools webViewTools,
     Postprocessing.IModel postprocessingModel,
     IPluginsManager pluginsManager,
     ITraceSourceFactory traceSourceFactory,
     LogMedia.IFileSystem fileSystem
     )
 {
     this.SynchronizationContext = threadSync;
     this.ChangeNotification     = changeNotification;
     this.WebContentCache        = webCache;
     this.ContentCache           = contentCache;
     this.StorageManager         = storageManager;
     this.Bookmarks                  = bookmarks;
     this.SourcesManager             = sourcesManager;
     this.Threads                    = threads;
     this.TempFilesManager           = tempFilesManager;
     this.Preprocessing              = preprocessingModel;
     this.ProgressAggregator         = progressAggregator;
     this.LogProviderFactoryRegistry = logProviderFactoryRegistry;
     this.UserDefinedFormatsManager  = userDefinedFormatsManager;
     this.ProgressAggregatorsFactory = progressAggregatorsFactory;
     this.MRU                = mru;
     this.Shutdown           = shutdown;
     this.WebViewTools       = webViewTools;
     this.Postprocessing     = postprocessingModel;
     this.PluginsManager     = pluginsManager;
     this.TraceSourceFactory = traceSourceFactory;
     this.FileSystem         = fileSystem;
 }
コード例 #21
0
 public Presenter(
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     IPagePresentersRegistry registry,
     IRecentlyUsedEntities mru,
     IView view,
     IUserDefinedFormatsManager userDefinedFormatsManager,
     Func <IPagePresenter> formatDetectionPageFactory,
     FormatsWizard.IPresenter formatsWizardPresenter
     )
 {
     this.logProviderFactoryRegistry = logProviderFactoryRegistry;
     this.registry = registry;
     this.mru      = mru;
     this.view     = view;
     this.formatDetectionPageFactory = formatDetectionPageFactory;
     this.userDefinedFormatsManager  = userDefinedFormatsManager;
     this.formatsWizardPresenter     = formatsWizardPresenter;
 }
コード例 #22
0
 public static void RegisterFactories(ILogProviderFactoryRegistry registry, ITempFilesManager tempFiles)
 {
     registry.Register(new Factory(
                           "Azure Diagnostics Log",
                           "Windows Azure Diagnostics log that is stored in Azure Tables Storage table (WADLogsTable)",
                           new WADLogsTableProviderStrategy(),
                           tempFiles
                           ));
     registry.Register(new Factory(
                           "Azure Diagnostics Windows Event Log",
                           "Windows Azure operating system event log collected and stored in Azure Tables Storage table (WADWindowsEventLogsTable)",
                           new WADWindowsEventLogsTableProviderStrategy(),
                           tempFiles
                           ));
     registry.Register(new Factory(
                           "Azure Diagnostics Infrastructure Log",
                           "Windows Azure Diagnostics infrastructure log collected and stored in Azure Tables Storage table (WADDiagnosticInfrastructureLogsTable)",
                           new WADDiagnosticInfrastructureLogsTableProviderStrategy(),
                           tempFiles
                           ));
 }
コード例 #23
0
ファイル: ObjectsFactory.cs プロジェクト: pnelson786/logjoint
 public ObjectsFactory(
     IAlertPopup alerts,
     IFileDialogs fileDialogs,
     Help.IPresenter help,
     ILogProviderFactoryRegistry registry,
     IFormatDefinitionsRepository repo,
     IUserDefinedFormatsManager userDefinedFormatsManager,
     ITempFilesManager tempFilesManager,
     LogViewer.IPresenterFactory logViewerPresenterFactory,
     ViewFactories viewFactories
     )
 {
     this.viewFactories             = viewFactories;
     this.alerts                    = alerts;
     this.registry                  = registry;
     this.fileDialogs               = fileDialogs;
     this.userDefinedFormatsManager = userDefinedFormatsManager;
     this.help                      = help;
     this.repo                      = repo;
     this.tempFilesManager          = tempFilesManager;
     this.logViewerPresenterFactory = logViewerPresenterFactory;
 }
コード例 #24
0
 public static void RegisterInstances(ILogProviderFactoryRegistry registry)
 {
     registry.Register(WADLogsTableFactoryInstance);
     registry.Register(WADWindowsEventLogsTableFactoryInstance);
     registry.Register(WADDiagnosticInfrastructureLogsTableFactoryInstance);
 }
コード例 #25
0
        static void InitLogFactories(LJTraceSource tracer, IUserDefinedFormatsManager userDefinedFormatsManager, ILogProviderFactoryRegistry factoryRegistry)
        {
            using (tracer.NewFrame)
            {
                var asmsToAnalize = new Assembly[] {
                    Assembly.GetEntryAssembly(),
                    typeof(ILogSourcesManager).Assembly
                };
                var factoryTypes = asmsToAnalize.SelectMany(a => a.GetTypes())
                                   .Where(t => t.IsClass && typeof(ILogProviderFactory).IsAssignableFrom(t));

                foreach (Type t in factoryTypes)
                {
                    tracer.Info("initing factory {0}", t.FullName);
                    System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(t.TypeHandle);
                    var registrationMethod = (
                        from m in t.GetMethods(BindingFlags.Static | BindingFlags.Public)
                        where m.GetCustomAttributes(typeof(RegistrationMethodAttribute), true).Length == 1
                        let args = m.GetParameters()
                                   where args.Length == 1
                                   let isUserDefined = typeof(IUserDefinedFormatsManager) == args[0].ParameterType
                                                       let isBuiltin = typeof(ILogProviderFactoryRegistry) == args[0].ParameterType
                                                                       where isUserDefined || isBuiltin
                                                                       select new { Method = m, Arg = isUserDefined ? (object)userDefinedFormatsManager : (object)factoryRegistry }
                        ).FirstOrDefault();
                    if (registrationMethod != null)
                    {
                        t.InvokeMember(registrationMethod.Method.Name,
                                       BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static,
                                       null, null, new object[] { registrationMethod.Arg });
                    }
                }
            }
        }
コード例 #26
0
 public static void Register(ILogProviderFactoryRegistry registry)
 {
     registry.Register(Instance);
 }
コード例 #27
0
 public FormatAutodetect(Func <ILogProviderFactory, int> mruIndexGetter, ILogProviderFactoryRegistry factoriesRegistry, ITempFilesManager tempFilesManager)
 {
     this.mruIndexGetter    = mruIndexGetter;
     this.factoriesRegistry = factoriesRegistry;
     this.tempFilesManager  = tempFilesManager;
 }
コード例 #28
0
 public FormatAutodetect(IRecentlyUsedEntities recentlyUsedLogs, ILogProviderFactoryRegistry factoriesRegistry, ITempFilesManager tempFilesManager) :
     this(recentlyUsedLogs.MakeFactoryMRUIndexGetter(), factoriesRegistry, tempFilesManager)
 {
 }
コード例 #29
0
ファイル: Factory.cs プロジェクト: sabrogden/logjoint
 private static void RegisterWindowsOnlyFactories(ILogProviderFactoryRegistry logProviderFactoryRegistry)
 {
     logProviderFactoryRegistry.Register(new DebugOutput.Factory());
     logProviderFactoryRegistry.Register(new WindowsEventLog.Factory());
 }
コード例 #30
0
ファイル: FormatAutodetect.cs プロジェクト: rkapl123/logjoint
        static async Task <DetectedFormat> DetectFormat(
            string fileName,
            string loggableName,
            Func <ILogProviderFactory, int> mruIndexGetter,
            ILogProviderFactoryRegistry factoriesRegistry,
            CancellationToken cancellation,
            IFormatAutodetectionProgress progress,
            ITraceSourceFactory traceSourceFactory,
            LogMedia.IFileSystem fileSystem)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("fileName");
            }
            if (mruIndexGetter == null)
            {
                throw new ArgumentNullException("mru");
            }
            Func <Task <SimpleFileMedia> > createFileMedia = () => SimpleFileMedia.Create(fileSystem, SimpleFileMedia.CreateConnectionParamsFromFileName(fileName));
            var log = traceSourceFactory.CreateTraceSource("App", string.Format("fdtc.{0}", Interlocked.Increment(ref lastPerfOp)));

            using (new Profiling.Operation(log, string.Format("format detection of {0}", loggableName)))
                using (ILogSourceThreadsInternal threads = new LogSourceThreads())
                    using (var localCancellation = CancellationTokenSource.CreateLinkedTokenSource(cancellation))
                    {
                        var candidateFactories = GetOrderedListOfRelevantFactories(fileName, mruIndexGetter, factoriesRegistry).ToArray();
                        var ret = (await Task.WhenAll(candidateFactories.Select((factory, index) => (factory, index)).Select(async candidate =>
                        {
                            var(factory, idx) = candidate;
                            try
                            {
                                using (var perfOp = new Profiling.Operation(log, factory.ToString()))
                                    using (var fileMedia = await createFileMedia())
                                        using (var reader = ((IMediaBasedReaderFactory)factory).CreateMessagesReader(
                                                   new MediaBasedReaderParams(threads, fileMedia,
                                                                              MessagesReaderFlags.QuickFormatDetectionMode, parentLoggingPrefix: log.Prefix)))
                                        {
                                            if (progress != null)
                                            {
                                                progress.Trying(factory);
                                            }
                                            if (localCancellation.IsCancellationRequested)
                                            {
                                                perfOp.Milestone("cancelled");
                                                return(fmt: (DetectedFormat)null, idx);
                                            }
                                            await reader.UpdateAvailableBounds(false);
                                            perfOp.Milestone("bounds detected");
                                            var parser = await reader.CreateParser(new CreateParserParams(0, null,
                                                                                                          MessagesParserFlag.DisableMultithreading | MessagesParserFlag.DisableDejitter, MessagesParserDirection.Forward));
                                            try
                                            {
                                                if (await parser.ReadNext() != null)
                                                {
                                                    log.Info("Autodetected format of {0}: {1}", fileName, factory);
                                                    localCancellation.Cancel();
                                                    return(fmt: new DetectedFormat(factory, ((IFileBasedLogProviderFactory)factory).CreateParams(fileName)), idx);
                                                }
                                            }
                                            finally
                                            {
                                                await parser.Dispose();
                                            }
                                        }
                            }
                            catch (Exception e)
                            {
                                log.Error(e, "Failed to load '{0}' as {1}", fileName, factory);
                            }
                            return(fmt: (DetectedFormat)null, idx);
                        }))).Where(x => x.fmt != null).OrderBy(x => x.idx).Select(x => x.fmt).FirstOrDefault();
                        if (ret != null)
                        {
                            return(ret);
                        }
                        using (var fileMedia = await createFileMedia())
                        {
                            if (!await IOUtils.IsBinaryFile(fileMedia.DataStream))
                            {
                                log.Info("File does not look binary");
                                var factory = factoriesRegistry.Find(
                                    PlainText.Factory.CompanyName, PlainText.Factory.FormatName) as IFileBasedLogProviderFactory;
                                if (factory != null)
                                {
                                    log.Info("Fall back to plaintext format");
                                    return(new DetectedFormat(factory, factory.CreateParams(fileName)));
                                }
                            }
                        }
                    }
            return(null);
        }