public LiveLogProvider(ILogProviderHost host, ILogProviderFactory factory, IConnectionParams originalConnectionParams, DejitteringParams?dejitteringParams = null)
            :
            base(
                host,
                factory,
                CreateConnectionParams(originalConnectionParams, host.TempFilesManager),
                @params => new XmlFormat.MessagesReader(
                    @params,
                    XmlFormat.XmlFormatInfo.MakeNativeFormatInfo(LiveLogXMLWriter.OutputEncoding.EncodingName, dejitteringParams, new FormatViewOptions(rawViewAllowed: false), host.RegexFactory),
                    host.RegexFactory,
                    host.TraceSourceFactory
                    )
                )
        {
            this.trace = base.tracer;
            this.originalConnectionParams = new ConnectionParamsReadOnlyView(originalConnectionParams);
            using (trace.NewFrame)
            {
                try
                {
                    string fileName = base.connectionParamsReadonlyView[ConnectionParamsKeys.PathConnectionParam];

                    XmlWriterSettings xmlSettings = new XmlWriterSettings();
                    xmlSettings.CloseOutput        = true;
                    xmlSettings.ConformanceLevel   = ConformanceLevel.Fragment;
                    xmlSettings.OmitXmlDeclaration = false;
                    xmlSettings.Indent             = true;

                    output = new LiveLogXMLWriter(
                        new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read),
                        xmlSettings,
                        defaultBackupMaxFileSize
                        );
                    trace.Info("Output created");

                    stopEvt = new CancellationTokenSource();

                    listeningThread = new Thread(ListeningThreadProc);
                }
                catch (Exception e)
                {
                    trace.Error(e, "Failed to inistalize live log reader. Disposing what has been created so far.");
                    Dispose();
                    throw;
                }
            }
        }
Exemple #2
0
 abstract protected void LiveLogListen(CancellationToken stopEvt, LiveLogXMLWriter output);