コード例 #1
0
        public IPositionedMessagesParser CreateParser(CreateParserParams parserParams)
        {
            parserParams.EnsureRangeIsSet(this);

            var strategiesCache = new StreamParser.StrategiesCache()
            {
                MultiThreadedStrategy  = multiThreadedStrategy,
                SingleThreadedStrategy = singleThreadedStrategy
            };

            DejitteringParams?dejitteringParams = GetDejitteringParams();

            if (dejitteringParams != null && (parserParams.Flags & MessagesParserFlag.DisableDejitter) == 0)
            {
                return(new DejitteringMessagesParser(
                           underlyingParserParams => new StreamParser(
                               this,
                               EnsureParserRangeDoesNotExceedReadersBoundaries(underlyingParserParams),
                               textStreamPositioningParams,
                               settingsAccessor,
                               strategiesCache
                               ),
                           parserParams,
                           dejitteringParams.Value
                           ));
            }
            return(new StreamParser(
                       this,
                       parserParams,
                       textStreamPositioningParams,
                       settingsAccessor,
                       strategiesCache
                       ));
        }
コード例 #2
0
        public UserDefinedFormatFactory(UserDefinedFactoryParams createParams)
            : base(createParams)
        {
            var formatSpecificNode = createParams.FormatSpecificNode;

            ReadPatterns(formatSpecificNode, patterns);

            var boundsNodes = formatSpecificNode.Elements("bounds").Take(1);
            var beginFinder = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("begin")).FirstOrDefault());
            var endFinder   = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("end")).FirstOrDefault());

            this.tempFilesManager = createParams.TempFilesManager;

            formatInfo = new Lazy <JsonFormatInfo>(() =>
            {
                string transform = ReadParameter(formatSpecificNode, "transform");
                if (transform == null)
                {
                    throw new Exception("Wrong JSON format definition: transform is not defined");
                }

                LoadedRegex head = ReadRe(formatSpecificNode, "head-re", ReOptions.Multiline);
                LoadedRegex body = ReadRe(formatSpecificNode, "body-re", ReOptions.Singleline);
                string encoding  = ReadParameter(formatSpecificNode, "encoding");

                DejitteringParams?dejitteringParams = DejitteringParams.FromConfigNode(
                    formatSpecificNode.Element("dejitter"));

                TextStreamPositioningParams textStreamPositioningParams = TextStreamPositioningParams.FromConfigNode(
                    formatSpecificNode);

                return(new JsonFormatInfo(transform, head, body, beginFinder, endFinder,
                                          encoding, textStreamPositioningParams, dejitteringParams, viewOptions));
            });
        }
コード例 #3
0
ファイル: XmlLogReader.cs プロジェクト: pnelson786/logjoint
        public static XmlFormatInfo MakeNativeFormatInfo(string encoding, DejitteringParams?dejitteringParams, FormatViewOptions viewOptions)
        {
            LoadedRegex headRe;

            headRe.Regex = RegexFactory.Instance.Create(@"\<\s*(m|f|ef)\s", ReOptions.None);
            headRe.SuffersFromPartialMatchProblem = false;
            return(new XmlFormatInfo(
                       null, headRe, new LoadedRegex(),
                       null, null, encoding, null, TextStreamPositioningParams.Default, dejitteringParams, viewOptions));
        }
コード例 #4
0
ファイル: RegularLogReader.cs プロジェクト: rkapl123/logjoint
        public UserDefinedFormatFactory(UserDefinedFactoryParams createParams)
            : base(createParams)
        {
            var formatSpecificNode = createParams.FormatSpecificNode;

            ReadPatterns(formatSpecificNode, patterns);
            var boundsNodes = formatSpecificNode.Elements("bounds").Take(1);
            var beginFinder = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("begin")).FirstOrDefault());
            var endFinder   = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("end")).FirstOrDefault());

            tempFilesManager       = createParams.TempFilesManager;
            fieldsProcessorFactory = createParams.FieldsProcessorFactory;
            regexFactory           = createParams.RegexFactory;
            traceSourceFactory     = createParams.TraceSourceFactory;
            fmtInfo = new Lazy <FormatInfo>(() =>
            {
                FieldsProcessor.IInitializationParams fieldsInitParams = fieldsProcessorFactory.CreateInitializationParams(
                    formatSpecificNode.Element("fields-config"), performChecks: true);
                MessagesReaderExtensions.XmlInitializationParams extensionsInitData = new MessagesReaderExtensions.XmlInitializationParams(
                    formatSpecificNode.Element("extensions"));
                DejitteringParams?dejitteringParams = DejitteringParams.FromConfigNode(
                    formatSpecificNode.Element("dejitter"));
                TextStreamPositioningParams textStreamPositioningParams = TextStreamPositioningParams.FromConfigNode(
                    formatSpecificNode);
                RotationParams rotationParams = RotationParams.FromConfigNode(
                    formatSpecificNode.Element("rotation"));
                FormatInfo.FormatFlags flags = FormatInfo.FormatFlags.None;
                if (formatSpecificNode.Element("plain-text-search-optimization").AttributeValue("allowed") == "yes")
                {
                    flags |= FormatInfo.FormatFlags.AllowPlainTextSearchOptimization;
                }
                return(new FormatInfo(
                           ReadRe(formatSpecificNode, "head-re", ReOptions.Multiline),
                           ReadRe(formatSpecificNode, "body-re", ReOptions.Singleline),
                           ReadParameter(formatSpecificNode, "encoding"),
                           fieldsInitParams,
                           extensionsInitData,
                           dejitteringParams,
                           textStreamPositioningParams,
                           flags,
                           rotationParams,
                           beginFinder,
                           endFinder
                           ));
            });
            uiKey = ReadParameter(formatSpecificNode, "ui-key");
        }
コード例 #5
0
 public JsonFormatInfo(
     string transform, LoadedRegex headRe, LoadedRegex bodyRe,
     BoundFinder beginFinder, BoundFinder endFinder, string encoding,
     TextStreamPositioningParams textStreamPositioningParams,
     DejitteringParams?dejitteringParams, IFormatViewOptions viewOptions) :
     base(MessagesReaderExtensions.XmlInitializationParams.Empty)
 {
     Encoding    = encoding;
     HeadRe      = headRe;
     BodyRe      = bodyRe;
     BeginFinder = beginFinder;
     EndFinder   = endFinder;
     TextStreamPositioningParams = textStreamPositioningParams;
     DejitteringParams           = dejitteringParams;
     ViewOptions = viewOptions;
     Transform   = JObject.Parse(transform);
 }
コード例 #6
0
        public SearchingParser(
            IPositionedMessagesReader owner,
            CreateSearchingParserParams p,
            TextStreamPositioningParams textStreamPositioningParams,
            DejitteringParams?dejitteringParams,
            Stream rawStream,
            Encoding streamEncoding,
            bool allowPlainTextSearchOptimization,
            LoadedRegex headerRe,
            ILogSourceThreads threads,
            ITraceSourceFactory traceSourceFactory,
            RegularExpressions.IRegexFactory regexFactory
            )
        {
            this.owner        = owner;
            this.parserParams = p;
            this.plainTextSearchOptimizationAllowed = allowPlainTextSearchOptimization && ((p.Flags & MessagesParserFlag.DisablePlainTextSearchOptimization) == 0);
            this.threads        = threads;
            this.requestedRange = p.Range;
            this.textStreamPositioningParams = textStreamPositioningParams;
            this.dejitteringParams           = dejitteringParams;
            this.rawStream      = rawStream;
            this.streamEncoding = streamEncoding;
            this.regexFactory   = regexFactory;
            this.trace          = traceSourceFactory.CreateTraceSource("LogSource", "srchp." + GetHashCode().ToString("x"));
            this.dummyFilter    = new Filter(FilterAction.Include, "", true, new Search.Options(), null, regexFactory);
            var continuationToken = p.ContinuationToken as ContinuationToken;

            if (continuationToken != null)
            {
                this.requestedRange = new FileRange.Range(continuationToken.NextPosition, requestedRange.End);
            }
            this.aligmentTextAccess      = new StreamTextAccess(rawStream, streamEncoding, textStreamPositioningParams);
            this.aligmentSplitter        = new MessagesSplitter(aligmentTextAccess, headerRe.Clone().Regex, headerRe.GetHeaderReSplitterFlags());
            this.aligmentCapture         = new TextMessageCapture();
            this.progressAndCancellation = new ProgressAndCancellation()
            {
                progressHandler   = p.ProgressHandler,
                cancellationToken = p.Cancellation,
                continuationToken = new ContinuationToken()
                {
                    NextPosition = requestedRange.Begin
                }
            };
            this.impl = Enum();
        }
コード例 #7
0
ファイル: XmlLogReader.cs プロジェクト: pnelson786/logjoint
        public XmlFormatInfo(XmlNode xsl, LoadedRegex headRe, LoadedRegex bodyRe, BoundFinder beginFinder, BoundFinder endFinder, string encoding, MessagesReaderExtensions.XmlInitializationParams extensionsInitData,
                             TextStreamPositioningParams textStreamPositioningParams, DejitteringParams?dejitteringParams, IFormatViewOptions viewOptions) :
            base(extensionsInitData)
        {
            Encoding    = encoding;
            HeadRe      = headRe;
            BodyRe      = bodyRe;
            BeginFinder = beginFinder;
            EndFinder   = endFinder;
            TextStreamPositioningParams = textStreamPositioningParams;
            DejitteringParams           = dejitteringParams;
            ViewOptions = viewOptions;

            if (xsl != null)
            {
                Dictionary <string, string> nsTable = new Dictionary <string, string>();
                foreach (XmlAttribute ns in xsl.SelectNodes(".//namespace::*"))
                {
                    if (ns.Value == "http://www.w3.org/XML/1998/namespace")
                    {
                        continue;
                    }
                    if (ns.Value == "http://www.w3.org/1999/XSL/Transform")
                    {
                        continue;
                    }
                    if (ns.Value == Properties.LogJointNS)
                    {
                        continue;
                    }
                    nsTable[ns.Name] = ns.Value;
                }

                StringBuilder nsdeclBuilder = new StringBuilder();
                foreach (KeyValuePair <string, string> ns in nsTable)
                {
                    nsdeclBuilder.AppendFormat("{0}='{1}' ", ns.Key, ns.Value);
                }
                NSDeclaration = nsdeclBuilder.ToString();

                Transform = new XslCompiledTransform();
                Transform.Load(xsl);
            }
        }
コード例 #8
0
        public UserDefinedFormatFactory(UserDefinedFactoryParams createParams)
            : base(createParams)
        {
            var formatSpecificNode = createParams.FormatSpecificNode;

            ReadPatterns(formatSpecificNode, patterns);

            var boundsNodes = formatSpecificNode.Elements("bounds").Take(1);
            var beginFinder = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("begin")).FirstOrDefault());
            var endFinder   = BoundFinder.CreateBoundFinder(boundsNodes.Select(n => n.Element("end")).FirstOrDefault());

            this.tempFilesManager   = createParams.TempFilesManager;
            this.regexFactory       = createParams.RegexFactory;
            this.traceSourceFactory = createParams.TraceSourceFactory;

            formatInfo = new Lazy <XmlFormatInfo>(() =>
            {
                XmlDocument tmpDoc = new XmlDocument();
                tmpDoc.LoadXml(formatSpecificNode.ToString());
                XmlElement xsl = tmpDoc.DocumentElement.SelectSingleNode("xsl:stylesheet", nsMgr) as XmlElement;
                if (xsl == null)
                {
                    throw new Exception("Wrong XML-based format definition: xsl:stylesheet is not defined");
                }

                LoadedRegex head = ReadRe(formatSpecificNode, "head-re", ReOptions.Multiline);
                LoadedRegex body = ReadRe(formatSpecificNode, "body-re", ReOptions.Singleline);
                string encoding  = ReadParameter(formatSpecificNode, "encoding");

                MessagesReaderExtensions.XmlInitializationParams extensionsInitData =
                    new MessagesReaderExtensions.XmlInitializationParams(formatSpecificNode.Element("extensions"));

                DejitteringParams?dejitteringParams = DejitteringParams.FromConfigNode(
                    formatSpecificNode.Element("dejitter"));

                TextStreamPositioningParams textStreamPositioningParams = TextStreamPositioningParams.FromConfigNode(
                    formatSpecificNode);

                return(new XmlFormatInfo(xsl, head, body, beginFinder, endFinder,
                                         encoding, extensionsInitData, textStreamPositioningParams, dejitteringParams, viewOptions));
            });
            uiKey = ReadParameter(formatSpecificNode, "ui-key");
        }
コード例 #9
0
 public FormatInfo(
     LoadedRegex headRe, LoadedRegex bodyRe,
     string encoding, FieldsProcessor.InitializationParams fieldsParams,
     MessagesReaderExtensions.XmlInitializationParams extensionsInitData,
     DejitteringParams?dejitteringParams,
     TextStreamPositioningParams textStreamPositioningParams,
     FormatFlags flags,
     RotationParams rotationParams
     ) :
     base(extensionsInitData)
 {
     this.HeadRe   = headRe;
     this.BodyRe   = bodyRe;
     this.Encoding = encoding;
     this.FieldsProcessorParams       = fieldsParams;
     this.DejitteringParams           = dejitteringParams;
     this.TextStreamPositioningParams = textStreamPositioningParams;
     this.Flags          = flags;
     this.RotationParams = rotationParams;
 }
コード例 #10
0
        public UserDefinedFormatFactory(UserDefinedFactoryParams createParams)
            : base(createParams)
        {
            var formatSpecificNode = createParams.FormatSpecificNode;

            ReadPatterns(formatSpecificNode, patterns);
            tempFilesManager = createParams.TempFilesManager;
            fmtInfo          = new Lazy <FormatInfo>(() =>
            {
                Type precompiledUserCode = ReadPrecompiledUserCode(createParams.RootNode);
                FieldsProcessor.InitializationParams fieldsInitParams = new FieldsProcessor.InitializationParams(
                    formatSpecificNode.Element("fields-config"), true, precompiledUserCode);
                MessagesReaderExtensions.XmlInitializationParams extensionsInitData = new MessagesReaderExtensions.XmlInitializationParams(
                    formatSpecificNode.Element("extensions"));
                DejitteringParams?dejitteringParams = DejitteringParams.FromConfigNode(
                    formatSpecificNode.Element("dejitter"));
                TextStreamPositioningParams textStreamPositioningParams = TextStreamPositioningParams.FromConfigNode(
                    formatSpecificNode);
                RotationParams rotationParams = RotationParams.FromConfigNode(
                    formatSpecificNode.Element("rotation"));
                FormatInfo.FormatFlags flags = FormatInfo.FormatFlags.None;
                if (formatSpecificNode.Element("plain-text-search-optimization").AttributeValue("allowed") == "yes")
                {
                    flags |= FormatInfo.FormatFlags.AllowPlainTextSearchOptimization;
                }
                return(new FormatInfo(
                           ReadRe(formatSpecificNode, "head-re", ReOptions.Multiline),
                           ReadRe(formatSpecificNode, "body-re", ReOptions.Singleline),
                           ReadParameter(formatSpecificNode, "encoding"),
                           fieldsInitParams,
                           extensionsInitData,
                           dejitteringParams,
                           textStreamPositioningParams,
                           flags,
                           rotationParams
                           ));
            });
            uiKey = ReadParameter(formatSpecificNode, "ui-key");
        }
コード例 #11
0
        public LiveLogProvider(ILogProviderHost host, ILogProviderFactory factory, IConnectionParams originalConnectionParams, DejitteringParams?dejitteringParams = null)
            :
            base(
                host,
                factory,
                CreateConnectionParams(originalConnectionParams, host.TempFilesManager),
                XmlFormat.XmlFormatInfo.MakeNativeFormatInfo(LiveLogXMLWriter.OutputEncoding.EncodingName, dejitteringParams, new FormatViewOptions(rawViewAllowed: false)),
                typeof(XmlFormat.MessagesReader)
                )
        {
            this.trace = base.tracer;
            this.originalConnectionParams = new ConnectionParamsReadOnlyView(originalConnectionParams);
            using (trace.NewFrame)
            {
                try
                {
                    string fileName = base.connectionParamsReadonlyView[ConnectionParamsUtils.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;
                }
            }
        }