Example #1
0
        //
        // For console application this is the entry point.
        //
        public void RunTask(String FrutiTracesFileName)
        {
            try
            {
                using (StreamReader sr = File.OpenText(FrutiTracesFileName))
                {
                    String input;
                    while ((input = sr.ReadLine()) != null)
                    {
                        input.Trim();
                        if (!input.Equals(" "))
                        {
                            TraceObject frutiTraceObject = new TraceObject();

                            Console.WriteLine("\n---------------------");
                            Console.WriteLine(input);
                            HvrMonitor.ParseTraceLine(input, ref frutiTraceObject);
                            frutiTraceObject.PrintTraceObject();
                            Console.WriteLine("---------------------");
                        }
                    }
                    Console.WriteLine("The end of the stream has been reached.");
                }
            }
            catch (Exception ex)
            {
                // Let the user know what went wrong.
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(ex.Message);
                Console.WriteLine("StackTrace: \n{0}", ex.StackTrace);
            }
        }
Example #2
0
        //
        // For console application this is the entry point.
        //
        public void RunTask(String FrutiTracesFileName)
        {
            try
            {
                using (StreamReader sr = File.OpenText(FrutiTracesFileName))
                {
                    String input;
                    while ((input = sr.ReadLine()) != null)
                    {
                        input.Trim();
                        if (!input.Equals(" "))
                        {
                            TraceObject frutiTraceObject = new TraceObject();

                            Console.WriteLine("\n---------------------");
                            Console.WriteLine(input);
                            HvrMonitor.ParseTraceLine(input, ref frutiTraceObject);
                            frutiTraceObject.PrintTraceObject();
                            Console.WriteLine("---------------------");
                        }
                    }
                    Console.WriteLine("The end of the stream has been reached.");
                }
            }
            catch (Exception ex)
            {
                // Let the user know what went wrong.
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(ex.Message);
                Console.WriteLine("StackTrace: \n{0}", ex.StackTrace);
            }
        }
Example #3
0
        // Parses a fruti trace line into an trace object.
        public static void ParseTraceLine(String FrutiTraceLine, ref TraceObject FrutiTraceObject)
        {
            //
            // Fruti Trace Format: [<Trace# EventId:Value> Time] | [FunctionName (FileName)] Trace Message.
            //
            try
            {
                String[] traceParts = FrutiTraceLine.Split(new Char[] { '|' });

                Int16    eventId;
                DateTime eventTime;
                ExtractIdAndTime(traceParts[0], out eventId, out eventTime);

                String functionName;
                String fileName;
                ExtractFunctionAndFileNames(traceParts[1], out functionName, out fileName);

                String messageTracePart = traceParts[1].Substring(traceParts[1].IndexOf(")]") + 2);
                messageTracePart.Trim();

                String vmName;
                Guid   vmGuid;
                String traceMessage;
                ExtractVmNameAndGuid(messageTracePart, out vmName, out vmGuid, out traceMessage);

                // File fruti trace object with extracted fields.
                FrutiTraceObject.EventId      = eventId;
                FrutiTraceObject.EventTime    = eventTime;
                FrutiTraceObject.FunctionName = functionName;
                FrutiTraceObject.FileName     = fileName;
                FrutiTraceObject.VmName       = vmName;
                FrutiTraceObject.VmGuid       = vmGuid;
                FrutiTraceObject.TraceMessage = traceMessage;
            }
            catch (Exception ex)
            {
                // Syntax error in the regular expression.
                Console.WriteLine("HvrMonitor::ParseTraceLine:{0}", ex.Message);
                Console.WriteLine("StackTrace: \n{0}", ex.StackTrace);
            }
        }
Example #4
0
        // Parses a fruti trace line into an trace object.
        public static void ParseTraceLine(String FrutiTraceLine, ref TraceObject FrutiTraceObject)
        {
            //
            // Fruti Trace Format: [<Trace# EventId:Value> Time] | [FunctionName (FileName)] Trace Message.
            //
            try
            {
                String[] traceParts = FrutiTraceLine.Split(new Char[] { '|' });

                Int16 eventId;
                DateTime eventTime;
                ExtractIdAndTime(traceParts[0], out eventId, out eventTime);

                String functionName;
                String fileName;
                ExtractFunctionAndFileNames(traceParts[1], out functionName, out fileName);

                String messageTracePart = traceParts[1].Substring(traceParts[1].IndexOf(")]") + 2);
                messageTracePart.Trim();

                String vmName;
                Guid vmGuid;
                String traceMessage;
                ExtractVmNameAndGuid(messageTracePart, out vmName, out vmGuid, out traceMessage);

                // File fruti trace object with extracted fields.
                FrutiTraceObject.EventId = eventId;
                FrutiTraceObject.EventTime = eventTime;
                FrutiTraceObject.FunctionName = functionName;
                FrutiTraceObject.FileName = fileName;
                FrutiTraceObject.VmName = vmName;
                FrutiTraceObject.VmGuid = vmGuid;
                FrutiTraceObject.TraceMessage = traceMessage;
            }
            catch (Exception ex)
            {
                // Syntax error in the regular expression.
                Console.WriteLine("HvrMonitor::ParseTraceLine:{0}", ex.Message);
                Console.WriteLine("StackTrace: \n{0}", ex.StackTrace);
            }
        }