Exemple #1
0
        public EventContainer parse(LogReceiver.LogEntry entry)
        {
            if (entry.len < 4)
            {
                return(null);
            }

            int inOffset = 0;

            int tagValue = ArrayHelper.swap32bitFromArray(entry.data, inOffset);

            inOffset += 4;

            string tag = mTagMap[tagValue];

            if (tag == null)
            {
                Log.e("EventLogParser", string.Format("unknown tag number: {0:D}", tagValue));
            }

            List <object> list = new List <object>();

            if (parseBinaryEvent(entry.data, inOffset, list) == -1)
            {
                return(null);
            }

            object data;

            if (list.Count == 1)
            {
                data = list[0];
            }
            else
            {
                data = list.ToArray();
            }

            EventContainer @event = null;

            if (tagValue == GcEventContainer.GC_EVENT_TAG)
            {
                @event = new GcEventContainer(entry, tagValue, data);
            }
            else
            {
                @event = new EventContainer(entry, tagValue, data);
            }

            return(@event);
        }
Exemple #2
0
        public EventContainer parse(string textLogLine)
        {
            // line will look like
            // 04-29 23:16:16.691 I/dvm_gc_info(  427): <data>
            // where <data> is either
            // [value1,value2...]
            // or
            // value
            if (textLogLine.Length == 0)
            {
                return(null);
            }

            // parse the header first
            var m = TEXT_LOG_LINE.Match(textLogLine);

            if (m.Success)
            {
                try
                {
                    int month        = Convert.ToInt32(m.Groups[0].Value);
                    int day          = Convert.ToInt32(m.Groups[1].Value);
                    int hours        = Convert.ToInt32(m.Groups[2].Value);
                    int minutes      = Convert.ToInt32(m.Groups[3].Value);
                    int seconds      = Convert.ToInt32(m.Groups[4].Value);
                    int milliseconds = Convert.ToInt32(m.Groups[5].Value);

                    // convert into seconds since epoch and nano-seconds.

                    /*Calendar cal = new GregorianCalendar();
                     * cal.set(cal.get(Calendar.YEAR), month - 1, day, hours, minutes, seconds);
                     * int sec = (int) Math.Floor(cal.timeInMillis/1000);
                     * int nsec = milliseconds*1000000;*/

                    var epoch = new DateTime(1970, 1, 1, 0, 0, 0);
                    var date  = new DateTime(DateTime.Now.Year, month, day, hours, minutes, 0);
                    var sec   = (int)Math.Floor(date.Subtract(epoch).TotalSeconds + seconds);
                    var nsec  = milliseconds * 1000000;

                    string tag = m.group(7);

                    // get the numerical tag value
                    int tagValue = -1;
                    //JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'entrySet' method:
                    var tagSet = mTagMap;
                    foreach (var entry in tagSet)
                    {
                        if (tag.Equals(entry.Value))
                        {
                            tagValue = entry.Key.Value;
                            break;
                        }
                    }

                    if (tagValue == -1)
                    {
                        return(null);
                    }

                    int pid = int.Parse(m.group(8));

                    object data = parseTextData(m.group(9), tagValue);
                    if (data == null)
                    {
                        return(null);
                    }

                    // now we can allocate and return the EventContainer
                    EventContainer @event = null;
                    if (tagValue == GcEventContainer.GC_EVENT_TAG)
                    {
                        @event = new GcEventContainer(tagValue, pid, -1, sec, nsec, data); // tid
                    }
                    else
                    {
                        @event = new EventContainer(tagValue, pid, -1, sec, nsec, data); // tid
                    }

                    return(@event);
                }
                catch (SystemException)
                {
                    return(null);
                }
            }

            return(null);
        }
Exemple #3
0
        public EventContainer parse(string textLogLine)
        {
            // line will look like
            // 04-29 23:16:16.691 I/dvm_gc_info(  427): <data>
            // where <data> is either
            // [value1,value2...]
            // or
            // value
            if (textLogLine.Length == 0)
            {
                return null;
            }

            // parse the header first
            var m = TEXT_LOG_LINE.Match(textLogLine);
            if (m.Success)
            {
                try
                {
                    int month = Convert.ToInt32(m.Groups[0].Value);
                    int day = Convert.ToInt32(m.Groups[1].Value);
                    int hours = Convert.ToInt32(m.Groups[2].Value);
                    int minutes = Convert.ToInt32(m.Groups[3].Value);
                    int seconds = Convert.ToInt32(m.Groups[4].Value);
                    int milliseconds = Convert.ToInt32(m.Groups[5].Value);

                    // convert into seconds since epoch and nano-seconds.
                    /*Calendar cal = new GregorianCalendar();
                    cal.set(cal.get(Calendar.YEAR), month - 1, day, hours, minutes, seconds);
                    int sec = (int) Math.Floor(cal.timeInMillis/1000);
                    int nsec = milliseconds*1000000;*/

                    var epoch = new DateTime(1970, 1, 1, 0, 0, 0);
                    var date = new DateTime(DateTime.Now.Year, month, day, hours, minutes, 0);
                    var sec = (int)Math.Floor(date.Subtract(epoch).TotalSeconds + seconds);
                    var nsec = milliseconds*1000000;

                    string tag = m.group(7);

                    // get the numerical tag value
                    int tagValue = -1;
                    //JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'entrySet' method:
                    var tagSet = mTagMap;
                    foreach (var entry in tagSet)
                    {
                        if (tag.Equals(entry.Value))
                        {
                            tagValue = entry.Key.Value;
                            break;
                        }
                    }

                    if (tagValue == -1)
                    {
                        return null;
                    }

                    int pid = int.Parse(m.group(8));

                    object data = parseTextData(m.group(9), tagValue);
                    if (data == null)
                    {
                        return null;
                    }

                    // now we can allocate and return the EventContainer
                    EventContainer @event = null;
                    if (tagValue == GcEventContainer.GC_EVENT_TAG)
                    {
                        @event = new GcEventContainer(tagValue, pid, -1, sec, nsec, data); // tid
                    }
                    else
                    {
                        @event = new EventContainer(tagValue, pid, -1, sec, nsec, data); // tid
                    }

                    return @event;
                }
                catch (SystemException)
                {
                    return null;
                }
            }

            return null;
        }
Exemple #4
0
        public EventContainer parse(LogReceiver.LogEntry entry)
        {
            if (entry.len < 4)
            {
                return null;
            }

            int inOffset = 0;

            int tagValue = ArrayHelper.swap32bitFromArray(entry.data, inOffset);
            inOffset += 4;

            string tag = mTagMap[tagValue];
            if (tag == null)
            {
                Log.e("EventLogParser", string.Format("unknown tag number: {0:D}", tagValue));
            }

            List<object> list = new List<object>();
            if (parseBinaryEvent(entry.data, inOffset, list) == -1)
            {
                return null;
            }

            object data;
            if (list.Count == 1)
            {
                data = list[0];
            }
            else
            {
                data = list.ToArray();
            }

            EventContainer @event = null;
            if (tagValue == GcEventContainer.GC_EVENT_TAG)
            {
                @event = new GcEventContainer(entry, tagValue, data);
            }
            else
            {
                @event = new EventContainer(entry, tagValue, data);
            }

            return @event;
        }